melonjs 19.4.0 → 19.6.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 (81) hide show
  1. package/README.md +18 -2
  2. package/build/application/application.d.ts.map +1 -1
  3. package/build/application/settings.d.ts +25 -2
  4. package/build/application/settings.d.ts.map +1 -1
  5. package/build/audio/audio.d.ts +77 -253
  6. package/build/audio/audio.d.ts.map +1 -1
  7. package/build/audio/backend.d.ts +121 -0
  8. package/build/audio/backend.d.ts.map +1 -0
  9. package/build/audio/playback.d.ts +157 -0
  10. package/build/audio/playback.d.ts.map +1 -0
  11. package/build/audio/procedural.d.ts +105 -0
  12. package/build/audio/procedural.d.ts.map +1 -0
  13. package/build/audio/types.d.ts +205 -0
  14. package/build/audio/types.d.ts.map +1 -0
  15. package/build/index.d.ts +6 -3
  16. package/build/index.d.ts.map +1 -1
  17. package/build/index.js +2447 -396
  18. package/build/index.js.map +4 -4
  19. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  20. package/build/level/tiled/TMXTileset.d.ts +12 -0
  21. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  22. package/build/level/tiled/factories/shape.d.ts +1 -1
  23. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  24. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  25. package/build/loader/loader.d.ts +2 -2
  26. package/build/loader/loader.d.ts.map +1 -1
  27. package/build/loader/parsers/aseprite.d.ts +37 -0
  28. package/build/loader/parsers/aseprite.d.ts.map +1 -0
  29. package/build/physics/adapter.d.ts +560 -0
  30. package/build/physics/adapter.d.ts.map +1 -0
  31. package/build/physics/bounds.d.ts +18 -5
  32. package/build/physics/bounds.d.ts.map +1 -1
  33. package/build/physics/builtin/body.d.ts +605 -0
  34. package/build/physics/builtin/body.d.ts.map +1 -0
  35. package/build/physics/builtin/builtin-adapter.d.ts +91 -0
  36. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -0
  37. package/build/physics/builtin/detector.d.ts +167 -0
  38. package/build/physics/builtin/detector.d.ts.map +1 -0
  39. package/build/physics/builtin/quadtree.d.ts +112 -0
  40. package/build/physics/builtin/quadtree.d.ts.map +1 -0
  41. package/build/physics/builtin/raycast.d.ts +4 -0
  42. package/build/physics/builtin/raycast.d.ts.map +1 -0
  43. package/build/physics/{sat.d.ts → builtin/sat.d.ts} +7 -7
  44. package/build/physics/builtin/sat.d.ts.map +1 -0
  45. package/build/physics/world.d.ts +61 -26
  46. package/build/physics/world.d.ts.map +1 -1
  47. package/build/renderable/collectable.d.ts +7 -1
  48. package/build/renderable/collectable.d.ts.map +1 -1
  49. package/build/renderable/container.d.ts +0 -13
  50. package/build/renderable/container.d.ts.map +1 -1
  51. package/build/renderable/renderable.d.ts +78 -17
  52. package/build/renderable/renderable.d.ts.map +1 -1
  53. package/build/renderable/trigger.d.ts +14 -1
  54. package/build/renderable/trigger.d.ts.map +1 -1
  55. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  56. package/build/system/timer.d.ts +0 -5
  57. package/build/system/timer.d.ts.map +1 -1
  58. package/build/video/canvas/canvas_renderer.d.ts +0 -130
  59. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  60. package/build/video/renderer.d.ts +111 -0
  61. package/build/video/renderer.d.ts.map +1 -1
  62. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  63. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  64. package/build/video/webgl/effects/shine.d.ts +87 -0
  65. package/build/video/webgl/effects/shine.d.ts.map +1 -0
  66. package/build/video/webgl/glshader.d.ts +46 -16
  67. package/build/video/webgl/glshader.d.ts.map +1 -1
  68. package/build/video/webgl/shadereffect.d.ts +23 -4
  69. package/build/video/webgl/shadereffect.d.ts.map +1 -1
  70. package/build/video/webgl/utils/uniforms.d.ts +8 -0
  71. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  72. package/build/video/webgl/webgl_renderer.d.ts +0 -106
  73. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  74. package/package.json +1 -1
  75. package/build/physics/body.d.ts +0 -351
  76. package/build/physics/body.d.ts.map +0 -1
  77. package/build/physics/detector.d.ts +0 -72
  78. package/build/physics/detector.d.ts.map +0 -1
  79. package/build/physics/quadtree.d.ts +0 -69
  80. package/build/physics/quadtree.d.ts.map +0 -1
  81. package/build/physics/sat.d.ts.map +0 -1
@@ -1,351 +0,0 @@
1
- /**
2
- * @import Entity from "./../renderable/entity/entity.js";
3
- * @import Container from "./../renderable/container.js";
4
- * @import Renderable from "./../renderable/renderable.js";
5
- * @import Sprite from "./../renderable/sprite.js";
6
- * @import NineSliceSprite from "./../renderable/nineslicesprite.js";
7
- * @import {Vector2d} from "../math/vector2d.js";
8
- * @import ResponseObject from "./response.js";
9
- **/
10
- /**
11
- * a Generic Physic Body Object with some physic properties and behavior functionality, to add as a member of a Renderable.
12
- * @category Physics
13
- * @see Renderable.body
14
- */
15
- export default class Body {
16
- /**
17
- * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} ancestor - the parent object this body is attached to
18
- * @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] - a initial shape, list of shapes, or JSON object defining the body
19
- * @param {Function} [onBodyUpdate] - callback for when the body is updated (e.g. add/remove shapes)
20
- */
21
- constructor(ancestor: Renderable | Container | Entity | Sprite | NineSliceSprite, shapes?: Rect | Rect[] | Polygon | Polygon[] | Line | Line[] | Ellipse | Ellipse[] | Point | Point[] | Bounds | Bounds[] | object, onBodyUpdate?: Function);
22
- /**
23
- * a reference to the parent object that contains this body,
24
- * or undefined if it has not been added to one.
25
- * @public
26
- * @type {Renderable|Container|Entity|Sprite|NineSliceSprite}
27
- * @default undefined
28
- */
29
- public ancestor: Renderable | Container | Entity | Sprite | NineSliceSprite;
30
- /**
31
- * The AABB bounds box representing this body
32
- * @public
33
- * @type {Bounds}
34
- */
35
- public bounds: Bounds;
36
- /**
37
- * The collision shapes of the body
38
- * @ignore
39
- * @type {Polygon[]|Line[]|Ellipse[]|Point|Point[]}
40
- */
41
- shapes: Polygon[] | Line[] | Ellipse[] | Point | Point[];
42
- /**
43
- * The body collision mask, that defines what should collide with what.<br>
44
- * (by default will collide with all entities)
45
- * @ignore
46
- * @type {number}
47
- * @default collision.types.ALL_OBJECT
48
- * @see collision.types
49
- */
50
- collisionMask: number;
51
- /**
52
- * define the collision type of the body for collision filtering
53
- * @public
54
- * @type {number}
55
- * @default collision.types.ENEMY_OBJECT
56
- * @see collision.types
57
- * @example
58
- * // set the body collision type
59
- * body.collisionType = me.collision.types.PLAYER_OBJECT;
60
- */
61
- public collisionType: number;
62
- /**
63
- * The current velocity of the body.
64
- * See to apply a force if you need to modify a body velocity
65
- * @see Body.force
66
- * @public
67
- * @type {Vector2d}
68
- * @default <0,0>
69
- */
70
- public vel: Vector2d;
71
- /**
72
- * body force to apply to this the body in the current step.
73
- * (any positive or negative force will be cancelled after every world/body update cycle)
74
- * @public
75
- * @type {Vector2d}
76
- * @default <0,0>
77
- * @see Body.setMaxVelocity
78
- * @example
79
- * // define a default maximum acceleration, initial force and friction
80
- * this.body.force.set(1, 0);
81
- * this.body.friction.set(0.4, 0);
82
- * this.body.setMaxVelocity(3, 15);
83
- *
84
- * // apply a positive or negative force when pressing left of right key
85
- * update(dt) {
86
- * if (me.input.isKeyPressed("left")) {
87
- * this.body.force.x = -this.body.maxVel.x;
88
- * } else if (me.input.isKeyPressed("right")) {
89
- * this.body.force.x = this.body.maxVel.x;
90
- * }
91
- * }
92
- */
93
- public force: Vector2d;
94
- /**
95
- * body friction
96
- * @public
97
- * @type {Vector2d}
98
- * @default <0,0>
99
- */
100
- public friction: Vector2d;
101
- /**
102
- * the body bounciness level when colliding with other solid bodies :
103
- * a value of 0 will not bounce, a value of 1 will fully rebound.
104
- * @public
105
- * @type {number}
106
- * @default 0
107
- */
108
- public bounce: number;
109
- /**
110
- * the body mass
111
- * @public
112
- * @type {number}
113
- * @default 1
114
- */
115
- public mass: number;
116
- /**
117
- * max velocity (to limit body velocity)
118
- * @public
119
- * @type {Vector2d}
120
- * @default <490,490>
121
- */
122
- public maxVel: Vector2d;
123
- /**
124
- * Either this body is a static body or not.
125
- * A static body is completely fixed and can never change position or angle.
126
- * @readonly
127
- * @public
128
- * @type {boolean}
129
- * @default false
130
- */
131
- public readonly isStatic: boolean;
132
- /**
133
- * The degree to which this body is affected by the world gravity
134
- * @public
135
- * @see {@link World.gravity}
136
- * @type {number}
137
- * @default 1.0
138
- */
139
- public gravityScale: number;
140
- /**
141
- * If true this body won't be affected by the world gravity
142
- * @public
143
- * @see {@link World.gravity}
144
- * @type {boolean}
145
- * @default false
146
- */
147
- public ignoreGravity: boolean;
148
- /**
149
- * falling state of the body<br>
150
- * true if the object is falling<br>
151
- * false if the object is standing on something<br>
152
- * @readonly
153
- * @public
154
- * @type {boolean}
155
- * @default false
156
- */
157
- public readonly falling: boolean;
158
- /**
159
- * jumping state of the body<br>
160
- * equal true if the body is jumping<br>
161
- * @readonly
162
- * @public
163
- * @type {boolean}
164
- * @default false
165
- */
166
- public readonly jumping: boolean;
167
- onBodyUpdate: Function | undefined;
168
- /**
169
- * set the body as a static body
170
- * static body do not move automatically and do not check against collision with others
171
- * @param {boolean} [isStatic=true]
172
- */
173
- setStatic(isStatic?: boolean): void;
174
- /**
175
- * add a collision shape to this body <br>
176
- * (note: me.Rect objects will be converted to me.Polygon before being added)
177
- * @param {Rect|Polygon|Line|Ellipse|Point|Point[]|Bounds|object} shape - a shape or JSON object
178
- * @returns {number} the shape array length
179
- * @example
180
- * // add a rectangle shape
181
- * this.body.addShape(new me.Rect(0, 0, image.width, image.height));
182
- * // add a shape from a JSON object
183
- * this.body.addShape(me.loader.getJSON("shapesdef").banana);
184
- */
185
- addShape(shape: Rect | Polygon | Line | Ellipse | Point | Point[] | Bounds | object): number;
186
- /**
187
- * set the body vertices to the given one
188
- * @param {Vector2d[]} vertices - an array of me.Vector2d points defining a convex hull
189
- * @param {number} [index=0] - the shape object for which to set the vertices
190
- * @param {boolean} [clear=true] - either to reset the body definition before adding the new vertices
191
- */
192
- setVertices(vertices: Vector2d[], index?: number, clear?: boolean): void;
193
- /**
194
- * add the given vertices to the body shape
195
- * @param {Vector2d[]} vertices - an array of me.Vector2d points defining a convex hull
196
- * @param {number} [index=0] - the shape object for which to set the vertices
197
- */
198
- addVertices(vertices: Vector2d[], index?: number): void;
199
- /**
200
- * add collision mesh based on a JSON object
201
- * (this will also apply any physic properties defined in the given JSON file)
202
- * @param {object} json - a JSON object as exported from a Physics Editor tool
203
- * @param {string} [id] - an optional shape identifier within the given the json object
204
- * @see https://www.codeandweb.com/physicseditor
205
- * @returns {number} how many shapes were added to the body
206
- * @example
207
- * // define the body based on the banana shape
208
- * this.body.fromJSON(me.loader.getJSON("shapesdef").banana);
209
- * // or ...
210
- * this.body.fromJSON(me.loader.getJSON("shapesdef"), "banana");
211
- */
212
- fromJSON(json: object, id?: string): number;
213
- /**
214
- * return the collision shape at the given index
215
- * @param {number} [index=0] - the shape object at the specified index
216
- * @returns {Polygon|Line|Ellipse} shape a shape object if defined
217
- */
218
- getShape(index?: number): Polygon | Line | Ellipse;
219
- /**
220
- * returns the AABB bounding box for this body
221
- * @returns {Bounds} bounding box Rectangle object
222
- */
223
- getBounds(): Bounds;
224
- /**
225
- * remove the specified shape from the body shape list
226
- * @param {Polygon|Line|Ellipse} shape - a shape object
227
- * @returns {number} the shape array length
228
- */
229
- removeShape(shape: Polygon | Line | Ellipse): number;
230
- /**
231
- * remove the shape at the given index from the body shape list
232
- * @param {number} index - the shape object at the specified index
233
- * @returns {number} the shape array length
234
- */
235
- removeShapeAt(index: number): number;
236
- /**
237
- * By default all physic bodies are able to collide with all other bodies, <br>
238
- * but it's also possible to specify 'collision filters' to provide a finer <br>
239
- * control over which body can collide with each other.
240
- * @see collision.types
241
- * @param {number} [bitmask = collision.types.ALL_OBJECT] - the collision mask
242
- * @example
243
- * // filter collision detection with collision shapes, enemies and collectables
244
- * body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
245
- * ...
246
- * // disable collision detection with all other objects
247
- * body.setCollisionMask(me.collision.types.NO_OBJECT);
248
- */
249
- setCollisionMask(bitmask?: number): void;
250
- /**
251
- * define the collision type of the body for collision filtering
252
- * @see collision.types
253
- * @param {number} type - the collision type
254
- * @example
255
- * // set the body collision type
256
- * body.collisionType = me.collision.types.PLAYER_OBJECT;
257
- */
258
- setCollisionType(type: number): void;
259
- /**
260
- * the built-in function to solve the collision response
261
- * @param {ResponseObject} response - the collision response object
262
- * @see {@link ResponseObject}
263
- */
264
- respondToCollision(response: ResponseObject): void;
265
- /**
266
- * The forEach() method executes a provided function once per body shape element. <br>
267
- * the callback function is invoked with three arguments: <br>
268
- * - The current element being processed in the array <br>
269
- * - The index of element in the array. <br>
270
- * - The array forEach() was called upon. <br>
271
- * @param {Function} callback - function to execute on each element
272
- * @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
273
- * @example
274
- * // iterate through all shapes of the physic body
275
- * mySprite.body.forEach((shape) => {
276
- * shape.doSomething();
277
- * });
278
- * mySprite.body.forEach((shape, index) => { ... });
279
- * mySprite.body.forEach((shape, index, array) => { ... });
280
- * mySprite.body.forEach((shape, index, array) => { ... }, thisArg);
281
- */
282
- forEach(callback: Function, thisArg?: object): void;
283
- /**
284
- * Returns true if the any of the shape composing the body contains the given point.
285
- * @param {number|Vector2d} x - x coordinate or a vector point to check
286
- * @param {number} [y] - y coordinate
287
- * @returns {boolean} true if contains
288
- * @example
289
- * if (mySprite.body.contains(10, 10)) {
290
- * // do something
291
- * }
292
- * // or
293
- * if (mySprite.body.contains(myVector2d)) {
294
- * // do something
295
- * }
296
- */
297
- contains(...args: any[]): boolean;
298
- /**
299
- * Rotate this body (counter-clockwise) by the specified angle (in radians).
300
- * Unless specified the body will be rotated around its center point
301
- * @param {number} angle - The angle to rotate (in radians)
302
- * @param {Vector2d} [v=Body.getBounds().center] - an optional point to rotate around
303
- * @returns {Body} Reference to this object for method chaining
304
- */
305
- rotate(angle: number, v?: Vector2d): Body;
306
- /**
307
- * cap the body velocity (body.maxVel property) to the specified value<br>
308
- * @param {number} x - max velocity on x axis
309
- * @param {number} y - max velocity on y axis
310
- */
311
- setMaxVelocity(x: number, y: number): void;
312
- /**
313
- * set the body default friction
314
- * @param {number} x - horizontal friction
315
- * @param {number} y - vertical friction
316
- */
317
- setFriction(x?: number, y?: number): void;
318
- /**
319
- * Updates the parent's position as well as computes the new body's velocity based
320
- * on the values of force/friction. Velocity changes are proportional to the
321
- * me.timer.tick value (which can be used to scale velocities). The approach to moving the
322
- * parent renderable is to compute new values of the Body.vel property then add them to
323
- * the parent.pos value thus changing the position by the amount of Body.vel each time the
324
- * update call is made. <br>
325
- * Updates to Body.vel are bounded by maxVel (which defaults to viewport size if not set) <br>
326
- * At this time a call to Body.Update does not call the onBodyUpdate callback that is listed in the constructor arguments.
327
- * @protected
328
- * @param {number} dt - time since the last update in milliseconds.
329
- * @returns {boolean} true if resulting velocity is different than 0
330
- */
331
- protected update(): boolean;
332
- /**
333
- * Destroy function<br>
334
- * @ignore
335
- */
336
- destroy(): void;
337
- }
338
- import type Renderable from "./../renderable/renderable.js";
339
- import type Container from "./../renderable/container.js";
340
- import type Entity from "./../renderable/entity/entity.js";
341
- import type Sprite from "./../renderable/sprite.js";
342
- import type NineSliceSprite from "./../renderable/nineslicesprite.js";
343
- import { Bounds } from "./bounds.ts";
344
- import { Polygon } from "../geometries/polygon.ts";
345
- import { Line } from "./../geometries/line.ts";
346
- import { Ellipse } from "./../geometries/ellipse.ts";
347
- import { Point } from "../geometries/point.ts";
348
- import type { Vector2d } from "../math/vector2d.js";
349
- import { Rect } from "./../geometries/rectangle.ts";
350
- import type ResponseObject from "./response.js";
351
- //# sourceMappingURL=body.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"body.d.ts","sourceRoot":"","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AA4B;sBAEnB,wBAAwB;8BAiB9B,qBAAqB;qBAf3B,8BAA8B;gCAgBpB,eAAe"}
@@ -1,72 +0,0 @@
1
- export default Detector;
2
- /**
3
- * the Detector class contains methods for detecting collisions between bodies using a broadphase algorithm.
4
- */
5
- declare class Detector {
6
- /**
7
- * @param {Container} world - the physic world this detector is bind to
8
- */
9
- constructor(world: Container);
10
- world: Container;
11
- /**
12
- * the default response object used for collisions
13
- * (will be automatically populated by the collides functions)
14
- * @type {ResponseObject}
15
- */
16
- response: ResponseObject;
17
- /**
18
- * determine if two objects should collide (based on both respective objects body collision mask and type).<br>
19
- * you can redefine this function if you need any specific rules over what should collide with what.
20
- * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
21
- * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
22
- * @returns {boolean} true if they should collide, false otherwise
23
- */
24
- shouldCollide(a: Renderable | Container | Entity | Sprite | NineSliceSprite, b: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean;
25
- /**
26
- * detect collision between two bodies.
27
- * @param {Body} bodyA - a reference to body A.
28
- * @param {Body} bodyB - a reference to body B.
29
- * @returns {boolean} true if colliding
30
- */
31
- collides(bodyA: Body, bodyB: Body, response?: ResponseObject): boolean;
32
- /**
33
- * find all the collisions for the specified object using a broadphase algorithm
34
- * @ignore
35
- * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision
36
- * @returns {boolean} in case of collision, false otherwise
37
- */
38
- collisions(objA: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean;
39
- /**
40
- * Checks for object colliding with the given line
41
- * @ignore
42
- * @param {Line} line - line to be tested for collision
43
- * @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
44
- * @returns {Array.<Renderable>} an array of intersecting physic objects
45
- * @example
46
- * // define a line accross the viewport
47
- * let ray = new Line(
48
- * // absolute position of the line
49
- * 0, 0, [
50
- * // starting point relative to the initial position
51
- * new Vector2d(0, 0),
52
- * // ending point
53
- * new Vector2d(app.viewport.width, app.viewport.height)
54
- * ]);
55
- *
56
- * // check for collition
57
- * result = me.collision.rayCast(ray);
58
- *
59
- * if (result.length > 0) {
60
- * // ...
61
- * }
62
- */
63
- rayCast(line: Line, result?: Array<Renderable>): Array<Renderable>;
64
- }
65
- import type Container from "./../renderable/container.js";
66
- import ResponseObject from "./response.js";
67
- import type Renderable from "./../renderable/renderable.js";
68
- import type Entity from "./../renderable/entity/entity.js";
69
- import type Sprite from "./../renderable/sprite.js";
70
- import type NineSliceSprite from "./../renderable/nineslicesprite.js";
71
- import type { Line } from "./../geometries/line.ts";
72
- //# sourceMappingURL=detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/physics/detector.js"],"names":[],"mappings":";AAuDA;;GAEG;AACH;IACC;;OAEG;IACH,mBAFW,SAAS,EAYnB;IARA,iBAAkB;IAElB;;;;OAIG;IACH,UAFU,cAAc,CAEY;IAGrC;;;;;;OAMG;IACH,iBAJW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,KAClD,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,GAChD,OAAO,CAiBnB;IAED;;;;;OAKG;IACH,gBAJW,IAAI,SACJ,IAAI,8BACF,OAAO,CAkCnB;IAED;;;;;OAKG;IACH,iBAHW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,GAChD,OAAO,CAsGnB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,cArBW,IAAI,WACJ,KAAK,CAAE,UAAU,CAAC,GAChB,KAAK,CAAE,UAAU,CAAC,CAiE9B;CACD;2BA5RyB,8BAA8B;2BA/B7B,eAAe;4BAgCf,+BAA+B;wBAFnC,kCAAkC;wBAGlC,2BAA2B;iCAClB,oCAAoC;0BAC7C,yBAAyB"}
@@ -1,69 +0,0 @@
1
- /**
2
- * a QuadTree implementation in JavaScript, a 2d spatial subdivision algorithm.
3
- * @category Physics
4
- * @see game.world.broadphase
5
- */
6
- export default class QuadTree {
7
- /**
8
- * @param {World} world - the physic world this QuadTree belongs to
9
- * @param {Bounds} bounds - bounds of the node
10
- * @param {number} [max_objects=4] - max objects a node can hold before splitting into 4 subnodes
11
- * @param {number} [max_levels=4] - total max levels inside root Quadtree
12
- * @param {number} [level] - deepth level, required for subnodes
13
- */
14
- constructor(world: World, bounds: Bounds, max_objects?: number, max_levels?: number, level?: number);
15
- world: World;
16
- bounds: Bounds;
17
- max_objects: number;
18
- max_levels: number;
19
- level: number;
20
- objects: any[];
21
- nodes: any[];
22
- split(): void;
23
- getIndex(item: any): number;
24
- /**
25
- * Insert the given object container into the node.
26
- * @param {Container} container - group of objects to be added
27
- */
28
- insertContainer(container: Container): void;
29
- /**
30
- * Insert the given object into the node. If the node
31
- * exceeds the capacity, it will split and add all
32
- * objects to their corresponding subnodes.
33
- * @param {object} item - object to be added
34
- */
35
- insert(item: object): void;
36
- /**
37
- * Return all objects that could collide with the given object
38
- * @param {object} item - object to be checked against
39
- * @param {object} [fn] - a sorting function for the returned array
40
- * @returns {object[]} array with all detected objects
41
- */
42
- retrieve(item: object, fn?: object, result: any): object[];
43
- /**
44
- * Remove the given item from the quadtree.
45
- * (this function won't recalculate the impacted node)
46
- * @param {object} item - object to be removed
47
- * @returns {boolean} true if the item was found and removed.
48
- */
49
- remove(item: object): boolean;
50
- /**
51
- * return true if the node is prunable
52
- * @returns {boolean} true if the node is prunable
53
- */
54
- isPrunable(): boolean;
55
- /**
56
- * return true if the node has any children
57
- * @returns {boolean} true if the node has any children
58
- */
59
- hasChildren(): boolean;
60
- /**
61
- * clear the quadtree
62
- * @param {Bounds} [bounds=this.bounds] - the bounds to be cleared
63
- */
64
- clear(bounds?: Bounds): void;
65
- }
66
- import type World from "./world.js";
67
- import type { Bounds } from "./bounds.ts";
68
- import type Container from "./../renderable/container.js";
69
- //# sourceMappingURL=quadtree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"quadtree.d.ts","sourceRoot":"","sources":["../../src/physics/quadtree.js"],"names":[],"mappings":"AA2DA;;;;GAIG;AACH;IACC;;;;;;OAMG;IACH,mBANW,KAAK,UACL,MAAM,gBACN,MAAM,eACN,MAAM,UACN,MAAM,EAahB;IAVA,aAAkB;IAClB,eAAoB;IAEpB,oBAA8B;IAC9B,mBAA4B;IAE5B,cAAkB;IAElB,eAAiB;IACjB,aAAe;IAMhB,cA8DC;IAOD,4BA+CC;IAED;;;OAGG;IACH,2BAFW,SAAS,QAyBnB;IAED;;;;;OAKG;IACH,aAFW,MAAM,QAoChB;IAED;;;;;OAKG;IACH,eAJW,MAAM,OACN,MAAM,gBACJ,MAAM,EAAE,CAmCpB;IAED;;;;;OAKG;IACH,aAHW,MAAM,GACJ,OAAO,CAkCnB;IAED;;;OAGG;IACH,cAFa,OAAO,CAInB;IAED;;;OAGG;IACH,eAFa,OAAO,CAUnB;IAED;;;OAGG;IACH,eAFW,MAAM,QAsBhB;CACD;uBAlZqB,YAAY;4BAET,aAAa;2BADZ,8BAA8B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sat.d.ts","sourceRoot":"","sources":["../../src/physics/sat.js"],"names":[],"mappings":"AAiNA;;;;;;;;;GASG;AACH,sCAPW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,SAClD,OAAO,KACP,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,SAClD,OAAO,aACP,QAAQ,YAAC,GACP,OAAO,CA8CnB;AAED;;;;;;;;;;GAUG;AACH,sCARW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,YAClD,OAAO,KACP,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,YAClD,OAAO,aACP,QAAQ,YAAC,GAEP,OAAO,CAiEnB;AAED;;;;;;;;;GASG;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