melonjs 19.6.0 → 19.7.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 (114) hide show
  1. package/README.md +5 -4
  2. package/build/application/application.d.ts +34 -2
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/settings.d.ts +37 -1
  5. package/build/application/settings.d.ts.map +1 -1
  6. package/build/camera/camera2d.d.ts +59 -7
  7. package/build/camera/camera2d.d.ts.map +1 -1
  8. package/build/camera/camera3d.d.ts +335 -0
  9. package/build/camera/camera3d.d.ts.map +1 -0
  10. package/build/camera/frustum.d.ts +162 -0
  11. package/build/camera/frustum.d.ts.map +1 -0
  12. package/build/const.d.ts +30 -3
  13. package/build/const.d.ts.map +1 -1
  14. package/build/geometries/sphere.d.ts +105 -0
  15. package/build/geometries/sphere.d.ts.map +1 -0
  16. package/build/index.d.ts +6 -4
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +27489 -24693
  19. package/build/index.js.map +4 -4
  20. package/build/input/keyboard.d.ts.map +1 -1
  21. package/build/input/pointerevent.d.ts.map +1 -1
  22. package/build/lang/deprecated.d.ts +18 -0
  23. package/build/lang/deprecated.d.ts.map +1 -1
  24. package/build/loader/loadingscreen.d.ts +8 -0
  25. package/build/loader/loadingscreen.d.ts.map +1 -1
  26. package/build/loader/parsers/mtl.d.ts.map +1 -1
  27. package/build/loader/parsers/obj.d.ts.map +1 -1
  28. package/build/math/color.d.ts +43 -5
  29. package/build/math/color.d.ts.map +1 -1
  30. package/build/math/math.d.ts +44 -0
  31. package/build/math/math.d.ts.map +1 -1
  32. package/build/math/observableVector2d.d.ts +14 -2
  33. package/build/math/observableVector2d.d.ts.map +1 -1
  34. package/build/math/observableVector3d.d.ts +14 -2
  35. package/build/math/observableVector3d.d.ts.map +1 -1
  36. package/build/math/vector2d.d.ts +16 -2
  37. package/build/math/vector2d.d.ts.map +1 -1
  38. package/build/math/vector3d.d.ts +16 -2
  39. package/build/math/vector3d.d.ts.map +1 -1
  40. package/build/particles/emitter.d.ts.map +1 -1
  41. package/build/physics/adapter.d.ts +77 -0
  42. package/build/physics/adapter.d.ts.map +1 -1
  43. package/build/physics/broadphase/aabb3d.d.ts +115 -0
  44. package/build/physics/broadphase/aabb3d.d.ts.map +1 -0
  45. package/build/physics/broadphase/broadphase.d.ts +74 -0
  46. package/build/physics/broadphase/broadphase.d.ts.map +1 -0
  47. package/build/physics/broadphase/factory.d.ts +30 -0
  48. package/build/physics/broadphase/factory.d.ts.map +1 -0
  49. package/build/physics/broadphase/octree.d.ts +325 -0
  50. package/build/physics/broadphase/octree.d.ts.map +1 -0
  51. package/build/physics/broadphase/quadtree.d.ts +184 -0
  52. package/build/physics/broadphase/quadtree.d.ts.map +1 -0
  53. package/build/physics/builtin/body.d.ts +7 -3
  54. package/build/physics/builtin/body.d.ts.map +1 -1
  55. package/build/physics/builtin/builtin-adapter.d.ts +6 -1
  56. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  57. package/build/physics/builtin/raycast.d.ts.map +1 -1
  58. package/build/physics/world.d.ts +15 -4
  59. package/build/physics/world.d.ts.map +1 -1
  60. package/build/renderable/container.d.ts +51 -5
  61. package/build/renderable/container.d.ts.map +1 -1
  62. package/build/renderable/mesh.d.ts +85 -10
  63. package/build/renderable/mesh.d.ts.map +1 -1
  64. package/build/renderable/renderable.d.ts +9 -4
  65. package/build/renderable/renderable.d.ts.map +1 -1
  66. package/build/state/stage.d.ts +8 -0
  67. package/build/state/stage.d.ts.map +1 -1
  68. package/build/state/state.d.ts.map +1 -1
  69. package/build/system/device.d.ts +196 -310
  70. package/build/system/device.d.ts.map +1 -1
  71. package/build/system/event.d.ts +49 -0
  72. package/build/system/event.d.ts.map +1 -1
  73. package/build/system/fullscreen.d.ts +16 -0
  74. package/build/system/fullscreen.d.ts.map +1 -0
  75. package/build/system/platform.d.ts +32 -4
  76. package/build/system/platform.d.ts.map +1 -1
  77. package/build/system/timer.d.ts.map +1 -1
  78. package/build/utils/function.d.ts +7 -1
  79. package/build/utils/function.d.ts.map +1 -1
  80. package/build/utils/types.d.ts +5 -0
  81. package/build/utils/types.d.ts.map +1 -1
  82. package/build/video/buffer/vertex.d.ts +19 -4
  83. package/build/video/buffer/vertex.d.ts.map +1 -1
  84. package/build/video/canvas/canvas_renderer.d.ts +4 -4
  85. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  86. package/build/video/canvas_factory.d.ts +25 -0
  87. package/build/video/canvas_factory.d.ts.map +1 -0
  88. package/build/video/renderer.d.ts +89 -15
  89. package/build/video/renderer.d.ts.map +1 -1
  90. package/build/video/renderstate.d.ts +12 -0
  91. package/build/video/renderstate.d.ts.map +1 -1
  92. package/build/video/rendertarget/rendertarget.d.ts +3 -1
  93. package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
  94. package/build/video/texture/cache.d.ts +5 -0
  95. package/build/video/texture/cache.d.ts.map +1 -1
  96. package/build/video/texture/resource.d.ts +22 -14
  97. package/build/video/texture/resource.d.ts.map +1 -1
  98. package/build/video/video.d.ts +3 -1
  99. package/build/video/video.d.ts.map +1 -1
  100. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  101. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  102. package/build/video/webgl/batchers/material_batcher.d.ts +9 -0
  103. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  104. package/build/video/webgl/batchers/mesh_batcher.d.ts +45 -1
  105. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  106. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  107. package/build/video/webgl/batchers/quad_batcher.d.ts +2 -2
  108. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  109. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  110. package/build/video/webgl/webgl_renderer.d.ts +2 -2
  111. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  112. package/package.json +3 -2
  113. package/build/physics/builtin/quadtree.d.ts +0 -112
  114. package/build/physics/builtin/quadtree.d.ts.map +0 -1
package/README.md CHANGED
@@ -54,7 +54,7 @@ Graphics
54
54
  - Built-in effects such as tinting, masking and 2D lighting (with optional per-pixel normal-map shading on sprites for 3D-looking dynamic lights)
55
55
  - Standard spritesheet, single and multiple Packed Textures support
56
56
  - Compressed texture support (DDS, KTX, KTX2, PVR, PKM) with automatic format detection and fallback
57
- - 3D mesh rendering with OBJ/MTL model loading, perspective projection and hardware depth testing
57
+ - 3D mesh rendering with OBJ/MTL model loading, multi-material support, perspective projection and hardware depth testing
58
58
  - Built-in shader effects (Flash, Outline, Glow, Dissolve, CRT, Hologram, etc.) with multi-pass chaining via `postEffects`, plus custom shader support via `ShaderEffect` for per-sprite fragment effects (WebGL)
59
59
  - Trail renderable for fading, tapering ribbons behind moving objects (speed lines, sword slashes, magic trails)
60
60
  - System & Bitmap Text with built-in typewriter effect
@@ -67,8 +67,8 @@ Sound
67
67
 
68
68
  Physics
69
69
  - Polygon (SAT) based collision algorithm for accurate detection and response
70
- - Fast broad-phase collision detection using spatial partitioning (QuadTree)
71
- - Raycast and AABB region queries with precise entry geometry
70
+ - Fast broad-phase collision detection using spatial partitioning (QuadTree in 2D, Octree in 3D, swapped automatically)
71
+ - Raycast, AABB and sphere region queries with precise entry geometry, including 3D raycasts (`raycast3d`)
72
72
  - Collision lifecycle hooks on every `Renderable`
73
73
  - Collision filtering for optimized automatic collision detection
74
74
  - Multiple shapes per body for complex hitboxes
@@ -82,7 +82,8 @@ Input
82
82
 
83
83
  Camera
84
84
  - Multi-camera support (split-screen, minimaps, multiple viewports)
85
- - Camera follow with configurable deadzone and damping
85
+ - Optional perspective camera (`Camera3d`) with frustum culling for 2.5D / 3D-projected scenes — drop-in subclass of the default 2D camera
86
+ - Camera follow with configurable deadzone and frame-rate-independent damping
86
87
  - Built-in shake, fade, flash, and mask-based transition effects
87
88
  - Per-camera post-processing pipeline with stackable shader effects and color grading (ColorMatrix)
88
89
 
@@ -137,8 +137,8 @@ export default class Application {
137
137
  * Accepted values : "x", "y", "z", "depth"
138
138
  * @see {@link World.sortOn}
139
139
  */
140
- get sortOn(): string;
141
- set sortOn(value: string);
140
+ get sortOn(): "x" | "y" | "z" | "depth";
141
+ set sortOn(value: "x" | "y" | "z" | "depth");
142
142
  /**
143
143
  * Fired when a level is fully loaded and all renderable instantiated. <br>
144
144
  * Additionally the level id will also be passed to the called function.
@@ -158,6 +158,38 @@ export default class Application {
158
158
  * @returns the parent HTML element
159
159
  */
160
160
  getParentElement(): HTMLElement;
161
+ /**
162
+ * Returns `true` if the browser/device is currently in fullscreen mode.
163
+ * Thin convenience around {@link device.isFullscreen} so the
164
+ * fullscreen trio (`isFullscreen` / `requestFullscreen` /
165
+ * `exitFullscreen`) lives together on the app instance.
166
+ * @category Application
167
+ */
168
+ isFullscreen(): boolean;
169
+ /**
170
+ * Trigger a fullscreen request for this application. Defaults to this
171
+ * application's `parentElement` (the container the canvas was appended
172
+ * into — see {@link Application#getParentElement}), so the canvas and
173
+ * any sibling HUD / overlay markup inside that container go fullscreen
174
+ * together.
175
+ * @param element - optional element to fullscreen instead of `this.parentElement`
176
+ * @example
177
+ * // bind F to toggle fullscreen
178
+ * me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
179
+ * me.event.on(me.event.KEYDOWN, (action) => {
180
+ * if (action === "toggleFullscreen") {
181
+ * if (!app.isFullscreen()) app.requestFullscreen();
182
+ * else app.exitFullscreen();
183
+ * }
184
+ * });
185
+ * @category Application
186
+ */
187
+ requestFullscreen(element?: Element): void;
188
+ /**
189
+ * Exit fullscreen mode for this application.
190
+ * @category Application
191
+ */
192
+ exitFullscreen(): void;
161
193
  /**
162
194
  * The HTML canvas element associated with this application's renderer.
163
195
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAGpD,OA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;OAMG;IACH,KAAK,CAAC,KAAK,GAAE,OAAe,GAAG,IAAI;IAInC;;;OAGG;IACH,MAAM,CAAC,KAAK,GAAE,OAAe,GAAG,IAAI;IAIpC;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,cAAc;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKzB,cAAc;IACd,OAAO,IAAI,IAAI;IASf,cAAc;IACd,QAAQ,IAAI,IAAI;IAShB;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA+C1B;;OAEG;IACH,IAAI,IAAI,IAAI;CAqBZ;AAED;;;;;GAKG;AACH,eAAO,IAAI,IAAI,EAAE,WAAW,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,QAE9C"}
@@ -2,6 +2,7 @@
2
2
  * additional import for TypeScript
3
3
  * @import Renderer from "./../video/renderer.js";
4
4
  */
5
+ import type Camera2d from "../camera/camera2d";
5
6
  import { RendererType } from "../const";
6
7
  import { PhysicsAdapter } from "../physics/adapter";
7
8
  import Renderer from "../video/renderer";
@@ -23,7 +24,22 @@ type PhysicsType = "builtin" | "none" | PhysicsAdapter | {
23
24
  type PowerPreference = "default" | "low-power";
24
25
  export type ApplicationSettings = {
25
26
  /**
26
- * renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
27
+ * Renderer to use. Three built-in modes (constants from `me.video`):
28
+ *
29
+ * - {@link CANVAS} — HTML5 Canvas backend. No shader / mesh /
30
+ * Camera3d support.
31
+ * - {@link WEBGL} — **requires WebGL**. Throws at `new Application(...)`
32
+ * time if WebGL is unavailable (driver-blocklisted GPU, perf-caveat
33
+ * failure, etc.). Use this when your scene needs Camera3d, Mesh,
34
+ * ShaderEffect, Light2d or GPU tilemap — you'd rather fail fast
35
+ * than render a stuck blank canvas.
36
+ * - {@link AUTO} — try WebGL, silently fall back to Canvas if
37
+ * unavailable. Application construction always succeeds. The
38
+ * WebGL-only subsystems (Camera3d, Mesh, ShaderEffect, Light2d,
39
+ * GPU tilemap) silently stop working under the Canvas fallback —
40
+ * if your scene depends on any of those, use `WEBGL` instead.
41
+ *
42
+ * Or pass a custom `Renderer` subclass instance for full control.
27
43
  * @default AUTO
28
44
  */
29
45
  renderer: RendererType | Renderer;
@@ -153,6 +169,26 @@ export type ApplicationSettings = {
153
169
  * a custom batcher class (WebGL only)
154
170
  */
155
171
  batcher?: (new (renderer: any) => Batcher) | undefined;
172
+ /**
173
+ * Default camera class instantiated for any {@link Stage} that does not
174
+ * explicitly provide its own cameras. Set to {@link Camera3d} to opt
175
+ * every stage in the app into perspective rendering by default. Stages
176
+ * can still override per-instance via `super({ cameras: [...] })` or
177
+ * per-class via `super({ cameraClass: Camera2d })`. Built-in stages
178
+ * (e.g. the loader screen) explicitly use {@link Camera2d} regardless
179
+ * of this setting.
180
+ *
181
+ * **WebGL requirement.** Camera classes whose
182
+ * `static defaultSortOn === "depth"` (Camera3d and any subclass) need
183
+ * the WebGL renderer — perspective projection, depth attachment and
184
+ * mesh draw all live in the WebGL backend. Pairing such a
185
+ * `cameraClass` with `renderer: video.AUTO` on a system where AUTO
186
+ * falls back to Canvas emits a `console.warn` at construction time
187
+ * and produces a non-functional render. Use `renderer: video.WEBGL`
188
+ * to get a hard throw instead.
189
+ * @default Camera2d
190
+ */
191
+ cameraClass?: new (minX: number, minY: number, maxX: number, maxY: number) => Camera2d;
156
192
  } & ({
157
193
  /**
158
194
  * the DOM parent element (or its string ID) to hold the canvas in the HTML file
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/application/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,C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AK,OAAO,CAAC,GAAG,SAAS,CAAC;IAEvD;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,KACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KACR,QAAQ,CAAC;CACd,GAAG,CACD;IACA;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,MAAM,CAAC,EAAE,KAAK,CAAC;CACd,GACD;IACA,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;;OAGG;IACH,MAAM,EAAE,iBAAiB,CAAC;CACzB,CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -38,6 +38,15 @@ interface AxisEnum {
38
38
  * this.cameras.set("minimap", minimap);
39
39
  */
40
40
  export default class Camera2d extends Renderable {
41
+ /**
42
+ * Preferred `Container.sortOn` mode for this camera type. Read by
43
+ * `Application` (and `Stage`) at bootstrap to initialize the world
44
+ * container's sort. Camera2d uses `"z"` (painter's-algorithm 2D
45
+ * layering, higher pos.z draws on top); `Camera3d` overrides to
46
+ * `"depth"` (camera-distance sort required by perspective).
47
+ * Subclasses can override to declare their own preferred mode.
48
+ */
49
+ static defaultSortOn: "x" | "y" | "z" | "depth";
41
50
  /**
42
51
  * Axis definition
43
52
  * NONE no axis
@@ -56,19 +65,37 @@ export default class Camera2d extends Renderable {
56
65
  */
57
66
  smoothFollow: boolean;
58
67
  /**
59
- * Camera damping for smooth transition [0 .. 1].
60
- * 1 being the maximum value and will snap the camera to the target position
68
+ * Camera damping for smooth follow `[0 .. 1]`. `1` snaps the camera
69
+ * to the target every frame (no smoothing); lower values produce a
70
+ * trailing follow — `0.1` is a soft springy follow, `0.5` is snappy.
71
+ *
72
+ * **Frame-rate independent (since 19.7 / #1478).** The value is the
73
+ * fraction of the gap covered per frame at the engine's target
74
+ * framerate ({@link timer.maxfps}, default 60). The underlying
75
+ * implementation switched from `pos.lerp` to `pos.damp` with
76
+ * `lambda = -ln(1 - damping) * timer.maxfps`, so the legacy
77
+ * per-frame fraction is recovered exactly at the target rate AND
78
+ * the wall-clock convergence stays constant when the actual frame
79
+ * rate drifts (slow machine, throttled tab, high-refresh display).
80
+ * Existing `damping` tuning carries over with no changes.
61
81
  * @default 1.0
62
82
  */
63
83
  damping: number;
64
84
  /**
65
- * the closest point relative to the camera
66
- * @default -1000
85
+ * the closest point relative to the camera. Widened from `-1000` in
86
+ * 19.7 to accommodate sprites at large `depth` values now that
87
+ * `aVertex.z` participates in clip-space (PR A): the default
88
+ * `Container.autoDepth = true` assigns `pos.z = childCount` so any
89
+ * container with >1000 children would otherwise clip-cull, and the
90
+ * common Y-sort pattern `sprite.depth = sprite.pos.y` exceeds 1000
91
+ * on tall maps. Override per-camera if you need tighter z clipping.
92
+ * @default -1e6
67
93
  */
68
94
  near: number;
69
95
  /**
70
- * the furthest point relative to the camera.
71
- * @default 1000
96
+ * the furthest point relative to the camera. Widened from `1000` in
97
+ * 19.7 — see {@link Camera2d#near}.
98
+ * @default 1e6
72
99
  */
73
100
  far: number;
74
101
  /**
@@ -253,7 +280,7 @@ export default class Camera2d extends Renderable {
253
280
  */
254
281
  moveTo(x: number, y: number): void;
255
282
  /** @ignore */
256
- updateTarget(_dt?: number): void;
283
+ updateTarget(dt?: number): void;
257
284
  /** @ignore */
258
285
  update(dt?: number): boolean;
259
286
  /**
@@ -347,6 +374,16 @@ export default class Camera2d extends Renderable {
347
374
  * @returns a vector with the converted local coordinates
348
375
  */
349
376
  worldToLocal(x: number, y: number, v?: Vector2d): Vector2d;
377
+ /**
378
+ * Build and install the world + screen projections used when this
379
+ * camera is non-default (split-screen, picture-in-picture, etc.).
380
+ * Default behavior is a shifted ortho that places the camera's
381
+ * world view at the camera's screen-rect within the full renderer
382
+ * viewport. Subclasses (e.g. Camera3d) override this to install a
383
+ * perspective `worldProjection` instead.
384
+ * @ignore
385
+ */
386
+ _setupNonDefaultProjection(renderer: Renderer): void;
350
387
  /**
351
388
  * render the camera effects
352
389
  * @ignore
@@ -357,6 +394,21 @@ export default class Camera2d extends Renderable {
357
394
  * @ignore
358
395
  */
359
396
  draw(renderer: Renderer, container: Container): void;
397
+ /**
398
+ * Apply the world-to-camera-view transform to the container before
399
+ * its draw walk. Camera2d translates by `-camera.pos` (plus shake
400
+ * offset); Camera3d overrides this to additionally rotate by
401
+ * `-camera.pitch` / `-camera.yaw` in the correct order.
402
+ * @ignore
403
+ */
404
+ _applyContainerViewTransform(container: Container, translateX: number, translateY: number): void;
405
+ /**
406
+ * Revert the transform applied by {@link Camera2d#_applyContainerViewTransform}.
407
+ * Must undo each mutation in reverse order. Subclasses overriding
408
+ * `_applyContainerViewTransform` should override this too.
409
+ * @ignore
410
+ */
411
+ _revertContainerViewTransform(container: Container, translateX: number, translateY: number): void;
360
412
  /**
361
413
  * @ignore
362
414
  */
@@ -1 +1 @@
1
- {"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../../src/camera/camera2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC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,UAAU,EAAE,MAAM,GAChB,IAAI;IAIP;;OAEG;IACM,OAAO,IAAI,IAAI;CAUxB"}
@@ -0,0 +1,335 @@
1
+ import type { ObservableVector3d } from "../math/observableVector3d.ts";
2
+ import { Vector3d } from "../math/vector3d.ts";
3
+ import type Container from "./../renderable/container.js";
4
+ import type Renderable from "./../renderable/renderable.js";
5
+ import type Renderer from "./../video/renderer.js";
6
+ import Camera2d from "./camera2d.ts";
7
+ import Frustum, { type FrustumOptions } from "./frustum.ts";
8
+ /**
9
+ * A perspective camera that extends {@link Camera2d} with a view
10
+ * {@link Frustum} (fov / aspect / near / far) and orientation
11
+ * (pitch / yaw / roll). Slots into `Stage.cameras` as a drop-in
12
+ * replacement for `Camera2d` — inherits the post-effect FBO bracket,
13
+ * color-matrix, fade / shake / follow plumbing, and screen viewport.
14
+ *
15
+ * **WebGL required.** Camera3d's perspective projection, depth-buffer
16
+ * painter sort and mesh draw path all live in the WebGL renderer; the
17
+ * Canvas backend has none of these and would render a stuck blank scene.
18
+ * Construct the Application with `renderer: video.WEBGL` to get a hard
19
+ * throw at construction time if WebGL is unavailable. Pairing
20
+ * `cameraClass: Camera3d` with `video.AUTO` will emit a `console.warn`
21
+ * at construction (and silently misrender) when AUTO falls back to
22
+ * Canvas — see {@link ApplicationSettings.renderer} for the contract.
23
+ *
24
+ * Conventions:
25
+ * - **Y-down + +Z forward.** Sprite at higher `pos.y` appears lower
26
+ * on screen (same as Camera2d). Sprite at higher `pos.z` is
27
+ * farther from the camera and renders smaller. Matches melonJS's
28
+ * 2D conventions so existing Camera2d code translates directly.
29
+ * - **Rotations are extrinsic XYZ.** `pitch` (X axis, look up/down),
30
+ * `yaw` (Y axis, look left/right), `roll` (Z axis, screen-plane
31
+ * bank — also exposed as `Camera2d.rotation` via Renderable
32
+ * inheritance for backward compatibility).
33
+ * - **Follow offset (PR B scope).** When a target is set,
34
+ * `followOffset` is applied in **world space**:
35
+ * `camera.pos = target.pos + followOffset`. Target-rotation-aware
36
+ * follow (Cinemachine / Unreal spring-arm style, where the offset
37
+ * rotates with the target's orientation) is deferred until a
38
+ * showcase needs it (e.g. AfterBurner's banking jet).
39
+ *
40
+ * Known limitations (PR B scope):
41
+ * - `Light2d` is 2D-only — visible artifacts under perspective.
42
+ * Avoid combining with Camera3d for now.
43
+ * - `localToWorld` / `worldToLocal` overrides fall back to the
44
+ * ortho-equivalent 2D projection at z=0. Full 3D unproject for
45
+ * arbitrary depth is future work.
46
+ * @category Camera
47
+ * @example
48
+ * // opt in app-wide:
49
+ * const app = new Application(1024, 768, {
50
+ * parent: "screen",
51
+ * cameraClass: Camera3d,
52
+ * });
53
+ *
54
+ * // or per-stage with custom fov:
55
+ * class GameStage extends Stage {
56
+ * constructor() {
57
+ * super({
58
+ * cameras: [new Camera3d(0, 0, 1024, 768, { fov: Math.PI / 3 })],
59
+ * });
60
+ * }
61
+ * }
62
+ */
63
+ export default class Camera3d extends Camera2d {
64
+ /**
65
+ * Override `Camera2d.defaultSortOn` to declare `"depth"` as this
66
+ * camera's preferred sort mode. `Application` / `Stage` apply this
67
+ * to `world.sortOn` at bootstrap, so games opting into Camera3d via
68
+ * `cameraClass: Camera3d` get camera-distance painter's sort for
69
+ * free — the only correct sort for alpha-blended sprites under
70
+ * perspective.
71
+ */
72
+ static defaultSortOn: "x" | "y" | "z" | "depth";
73
+ /**
74
+ * the view frustum (perspective parameters + projection matrix).
75
+ * Mutating `frustum.fov` / `aspect` / `near` / `far` directly
76
+ * requires calling `frustum.update()` to rebuild the matrix;
77
+ * the proxy setters on this camera (`camera.fov = ...`) handle
78
+ * that automatically.
79
+ */
80
+ frustum: Frustum;
81
+ /**
82
+ * X-axis rotation in radians (look up/down). Positive values
83
+ * pitch the camera up.
84
+ * @default 0
85
+ */
86
+ pitch: number;
87
+ /**
88
+ * Y-axis rotation in radians (look left/right). Positive values
89
+ * yaw the camera to the right.
90
+ * @default 0
91
+ */
92
+ yaw: number;
93
+ /**
94
+ * World-space offset from the followed target. When `target` is
95
+ * set via {@link Camera2d#follow}, the camera position resolves to
96
+ * `target.pos + followOffset`. Common usage: `(0, -2, -8)` for a
97
+ * behind-and-above third-person view.
98
+ *
99
+ * Treated as world-space in this release — target-rotation-aware
100
+ * follow (where the offset rotates with the target's orientation,
101
+ * Cinemachine / Unreal spring-arm style) is deferred until a
102
+ * showcase needs it (e.g. AfterBurner's banking jet).
103
+ * @default (0, 0, 0)
104
+ */
105
+ followOffset: Vector3d;
106
+ /**
107
+ * Reserved for future follow-look-ahead support — currently unused
108
+ * by `updateTarget`. The intent is: when wired in, the camera will
109
+ * look at `target.pos + lookAhead` instead of `target.pos`, so a
110
+ * follow-cam stays slightly ahead of its target (e.g. for a
111
+ * cinematic forward-looking shot in AfterBurner). Field is exposed
112
+ * now so user code can set it without waiting for the wiring.
113
+ * @default (0, 0, 1)
114
+ */
115
+ lookAhead: Vector3d;
116
+ /**
117
+ * @param minX - start x offset
118
+ * @param minY - start y offset
119
+ * @param maxX - end x offset
120
+ * @param maxY - end y offset
121
+ * @param [opts] - perspective parameters (see {@link FrustumOptions})
122
+ */
123
+ constructor(minX: number, minY: number, maxX: number, maxY: number, opts?: FrustumOptions);
124
+ /**
125
+ * vertical field of view in radians. Setting this rebuilds the
126
+ * projection matrix. Proxies to `frustum.fov`.
127
+ */
128
+ get fov(): number;
129
+ set fov(value: number);
130
+ /**
131
+ * aspect ratio (width / height). Auto-updated on `resize()`.
132
+ * Setting manually overrides the auto-derived value until the
133
+ * next resize. Proxies to `frustum.aspect`.
134
+ */
135
+ get aspect(): number;
136
+ set aspect(value: number);
137
+ /**
138
+ * Update the perspective near/far clip distances and rebuild the
139
+ * projection matrix in one shot. Anything closer than `near` or
140
+ * farther than `far` is clipped by the GPU; projection math also
141
+ * degrades sharply just before `far`, so size the far plane to the
142
+ * deepest object in your scene with a little headroom. Defaults are
143
+ * `near = 0.1`, `far = 1000` — typical AfterBurner-class scenes
144
+ * with enemies spawning at z = 3000+ need to push `far` out.
145
+ *
146
+ * **This is the supported way to change near/far at runtime.** The
147
+ * inherited `Camera2d.near` / `.far` are plain instance fields —
148
+ * direct assignment (`camera.near = 5`) updates the cached value
149
+ * but leaves the projection matrix stale until the next
150
+ * `resize()`. TypeScript's property-vs-accessor rule prevents
151
+ * shadowing the inherited fields with accessor pairs, so the
152
+ * convenience method is the public contract instead.
153
+ * @param near - near clip distance
154
+ * @param far - far clip distance
155
+ * @returns this camera (chainable)
156
+ */
157
+ setClipPlanes(near: number, far: number): this;
158
+ /**
159
+ * Rebuild the projection matrix from the frustum. Called by the
160
+ * base `Camera2d` constructor and by `resize()`. Camera3d's
161
+ * version replaces the ortho matrix with the frustum's perspective.
162
+ * @ignore
163
+ */
164
+ _updateProjectionMatrix(): void;
165
+ /**
166
+ * Override Camera2d's non-default projection setup so that a Camera3d
167
+ * used in split-screen / picture-in-picture still renders the world
168
+ * with perspective instead of falling back to a 2D ortho. The
169
+ * camera's perspective `projectionMatrix` is mirrored into
170
+ * `worldProjection`; the surrounding `clipRect` set by the base
171
+ * `draw()` handles confining the draw region to the camera's
172
+ * sub-screen rect, and the frustum's `aspect` is already in sync
173
+ * with the camera's width/height. `screenProjection` is left alone
174
+ * because it was already set up correctly in
175
+ * {@link Camera3d#_updateProjectionMatrix}.
176
+ * @ignore
177
+ */
178
+ _setupNonDefaultProjection(renderer: Renderer): void;
179
+ /**
180
+ * Resize the camera viewport and recompute aspect ratio.
181
+ * @param w - new width
182
+ * @param h - new height
183
+ * @returns this camera
184
+ */
185
+ resize(w: number, h: number): this;
186
+ /**
187
+ * Apply the camera's full 3D view transform to the world container.
188
+ * Order: rotate first (pitch, yaw), then translate by `-camera.pos`.
189
+ * Post-multiplication semantics give us
190
+ * `currentTransform = R⁻¹ ∘ T(-pos)` — applied to a world point,
191
+ * this subtracts the camera position then rotates by the camera's
192
+ * inverse orientation, which is the standard view transform.
193
+ * @ignore
194
+ */
195
+ _applyContainerViewTransform(container: Container, translateX: number, translateY: number): void;
196
+ /**
197
+ * Revert {@link Camera3d#_applyContainerViewTransform} in reverse
198
+ * order to restore the container's `currentTransform` to its
199
+ * pre-camera state.
200
+ * @ignore
201
+ */
202
+ _revertContainerViewTransform(container: Container, translateX: number, translateY: number): void;
203
+ /**
204
+ * Point the camera at a world-space target by deriving pitch and
205
+ * yaw from the direction (target − camera.pos). Roll is unaffected.
206
+ *
207
+ * Three call shapes:
208
+ * - `lookAt(x, y, z)` — raw world coordinates
209
+ * - `lookAt(vector3d)` — a 3D point
210
+ * - `lookAt(renderable)` — uses `renderable.pos` (matches the
211
+ * `Renderable.lookAt(target)` signature so Camera3d is a structural
212
+ * drop-in replacement for Camera2d / Renderable in user code).
213
+ *
214
+ * Last-write-wins with manual `pitch` / `yaw` assignment: if you
215
+ * call `lookAt(...)` then set `camera.pitch = 0.1` directly, the
216
+ * next frame renders with the manual pitch.
217
+ * @param xOrTarget - target world x, or a target with `pos` / `x`,`y`,`z`
218
+ * @param y - target world y (only when first arg is a number)
219
+ * @param z - target world z (only when first arg is a number)
220
+ * @returns this camera
221
+ */
222
+ lookAt(xOrTarget: number | {
223
+ x: number;
224
+ y: number;
225
+ z?: number;
226
+ pos?: ObservableVector3d;
227
+ }, y?: number, z?: number): this;
228
+ /**
229
+ * Convenience overload of `lookAt` accepting a {@link Vector3d}.
230
+ * @param target - world-space point to look at
231
+ * @returns this camera
232
+ */
233
+ setLookAt(target: Vector3d): this;
234
+ /**
235
+ * Set the target-local follow offset. Called once when configuring
236
+ * a follow-cam (e.g. behind-and-above third person:
237
+ * `setFollowOffset(0, -2, -8)`).
238
+ * @param x - target-local x offset
239
+ * @param y - target-local y offset
240
+ * @param z - target-local z offset
241
+ * @returns this camera
242
+ */
243
+ setFollowOffset(x: number, y: number, z: number): this;
244
+ /**
245
+ * Override Camera2d's 2D follow logic to additionally resolve
246
+ * `followOffset` against the target's z. When `target` is set, the
247
+ * camera's world position becomes `target.pos + followOffset`.
248
+ *
249
+ * **Semantic change vs Camera2d.follow:** this override **does not
250
+ * honor `follow_axis`, `deadzone`, or `smoothFollow` / `damping`**.
251
+ * Camera3d tracks its target exactly each frame because the typical
252
+ * 3D use case (behind-the-plane follow-cam, third-person orbit) wants
253
+ * 1:1 tracking with no scroll-deadzone. If you need damped or
254
+ * axis-constrained follow under perspective, set `target = null` and
255
+ * lerp `camera.pos` toward the target manually in your `update()`.
256
+ *
257
+ * **PR B scope:** `followOffset` is treated as **world-space**.
258
+ * Target-rotation-aware follow (where the offset rotates with the
259
+ * target's orientation, Cinemachine / Unreal-style) lands when a
260
+ * showcase (AfterBurner's banking jet) demands it.
261
+ * @param dt - delta time in milliseconds (ignored — no damping)
262
+ * @ignore
263
+ */
264
+ updateTarget(dt?: number): void;
265
+ /**
266
+ * Visibility check used by `Container.update` (in turn driving
267
+ * `Container.draw`) to skip rendering off-screen children.
268
+ *
269
+ * Camera2d's implementation tests a 2D bounds-rectangle overlap
270
+ * against `this.worldView` — that test is invalid under perspective:
271
+ * the visible region is a frustum that widens with distance and
272
+ * rotates with the camera's pitch / yaw, not a fixed axis-aligned
273
+ * rect at the camera's x / y. Camera3d substitutes plane-based
274
+ * frustum culling — each non-floating renderable's bounding sphere
275
+ * is tested against the six frustum planes that were extracted in
276
+ * the most recent `update()` call. Floating elements (HUD / UI)
277
+ * still use Camera2d's 2D rect test because their bounds are
278
+ * screen-space and the perspective transform doesn't apply to them.
279
+ * @param obj - the renderable to test
280
+ * @param [floating] - test against screen coordinates instead of frustum
281
+ * @returns true if the renderable's bounds overlap the frustum
282
+ */
283
+ isVisible(obj: Renderable, floating?: boolean): boolean;
284
+ /**
285
+ * Bulk frustum cull via the world's {@link Octree}. Returns every
286
+ * renderable whose octant the current frustum overlaps —
287
+ * conservative (some renderables may still narrow-cull out
288
+ * via {@link Camera3d#isVisible}'s per-sphere test) but
289
+ * O(visible + walk) instead of O(scene).
290
+ *
291
+ * Only applicable under `cameraClass: Camera3d` (or any setup
292
+ * where `world.sortOn === "depth"` and the broadphase is an
293
+ * Octree). Returns an empty array under a 2D broadphase — call
294
+ * sites can guard on the array length or branch on
295
+ * `world.sortOn`.
296
+ *
297
+ * For a 1000-renderable scene with ~50 visible, expect a 5-20×
298
+ * speedup over walking every renderable and per-item
299
+ * {@link Camera3d#isVisible}.
300
+ * @param world - the world to cull (its broadphase must be an Octree); typed structurally to sidestep the Camera3d → World import cycle
301
+ * @param world.broadphase - the world's spatial broadphase
302
+ * @param world.sortOn - guard: returns empty unless this equals `"depth"`
303
+ * @param [out] - caller-supplied result array (re-entrancy-safe)
304
+ * @returns visible-renderable candidates
305
+ * @example
306
+ * const visible = camera.queryVisible(app.world);
307
+ * for (const r of visible) {
308
+ * // narrow-phase per-renderable visibility (sphere / OBB) if needed
309
+ * if (camera.isVisible(r)) r.draw(renderer);
310
+ * }
311
+ */
312
+ queryVisible(world: {
313
+ broadphase: unknown;
314
+ sortOn: string;
315
+ }, out?: Renderable[]): Renderable[];
316
+ /**
317
+ * Per-frame update — extends Camera2d's behavior (target follow,
318
+ * camera effects) with rebuilding the frustum's six bounding
319
+ * planes so {@link Camera3d#isVisible} returns accurate results
320
+ * for the current camera state.
321
+ * @param dt - delta time in milliseconds
322
+ * @returns true if the camera's state changed
323
+ * @ignore
324
+ */
325
+ update(dt?: number): boolean;
326
+ /**
327
+ * Recompute the frustum's six bounding planes from the current
328
+ * `projectionMatrix × viewMatrix` (the world → clip matrix).
329
+ * Called from {@link Camera3d#update} each frame; `isVisible`
330
+ * then tests against the cached planes.
331
+ * @ignore
332
+ */
333
+ _rebuildFrustumPlanes(): void;
334
+ }
335
+ //# sourceMappingURL=camera3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera3d.d.ts","sourceRoot":"","sources":["../../src/camera/camera3d.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,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