melonjs 19.3.0 → 19.5.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.
- package/README.md +19 -2
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +37 -2
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +77 -253
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/backend.d.ts +121 -0
- package/build/audio/backend.d.ts.map +1 -0
- package/build/audio/playback.d.ts +157 -0
- package/build/audio/playback.d.ts.map +1 -0
- package/build/audio/procedural.d.ts +105 -0
- package/build/audio/procedural.d.ts.map +1 -0
- package/build/audio/types.d.ts +205 -0
- package/build/audio/types.d.ts.map +1 -0
- package/build/index.d.ts +6 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3334 -498
- package/build/index.js.map +4 -4
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +72 -5
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +19 -1
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +27 -0
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/factories/shape.d.ts +1 -1
- package/build/level/tiled/factories/shape.d.ts.map +1 -1
- package/build/level/tiled/factories/tile.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +7 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/loader/loader.d.ts +2 -2
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/aseprite.d.ts +37 -0
- package/build/loader/parsers/aseprite.d.ts.map +1 -0
- package/build/physics/adapter.d.ts +560 -0
- package/build/physics/adapter.d.ts.map +1 -0
- package/build/physics/bounds.d.ts +18 -5
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +605 -0
- package/build/physics/builtin/body.d.ts.map +1 -0
- package/build/physics/builtin/builtin-adapter.d.ts +91 -0
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -0
- package/build/physics/builtin/detector.d.ts +167 -0
- package/build/physics/builtin/detector.d.ts.map +1 -0
- package/build/physics/builtin/quadtree.d.ts +112 -0
- package/build/physics/builtin/quadtree.d.ts.map +1 -0
- package/build/physics/builtin/raycast.d.ts +4 -0
- package/build/physics/builtin/raycast.d.ts.map +1 -0
- package/build/physics/{sat.d.ts → builtin/sat.d.ts} +7 -7
- package/build/physics/builtin/sat.d.ts.map +1 -0
- package/build/physics/world.d.ts +77 -26
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/collectable.d.ts +7 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/container.d.ts +0 -13
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +78 -17
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +14 -1
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/system/timer.d.ts +0 -5
- package/build/system/timer.d.ts.map +1 -1
- package/build/utils/function.d.ts +1 -1
- package/build/utils/function.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +0 -130
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +126 -1
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/resource.d.ts +113 -0
- package/build/video/texture/resource.d.ts.map +1 -0
- package/build/video/webgl/batchers/material_batcher.d.ts +8 -1
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/effects/shine.d.ts +87 -0
- package/build/video/webgl/effects/shine.d.ts.map +1 -0
- package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +108 -0
- package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
- package/build/video/webgl/utils/attributes.d.ts +7 -0
- package/build/video/webgl/utils/attributes.d.ts.map +1 -1
- package/build/video/webgl/utils/precision.d.ts +1 -1
- package/build/video/webgl/utils/precision.d.ts.map +1 -1
- package/build/video/webgl/utils/uniforms.d.ts +13 -0
- package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +19 -106
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/build/physics/body.d.ts +0 -351
- package/build/physics/body.d.ts.map +0 -1
- package/build/physics/detector.d.ts +0 -72
- package/build/physics/detector.d.ts.map +0 -1
- package/build/physics/quadtree.d.ts +0 -69
- package/build/physics/quadtree.d.ts.map +0 -1
- package/build/physics/sat.d.ts.map +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Rect } from "../../geometries/rectangle.ts";
|
|
2
|
+
import { Vector2d } from "../../math/vector2d.ts";
|
|
3
|
+
import type Renderable from "../../renderable/renderable.js";
|
|
4
|
+
import type { AdapterCapabilities, AdapterOptions, BodyDefinition, BodyShape, PhysicsAdapter, RaycastHit } from "../adapter.ts";
|
|
5
|
+
import type { Bounds } from "../bounds.ts";
|
|
6
|
+
import type World from "../world.js";
|
|
7
|
+
import Body from "./body.js";
|
|
8
|
+
import Detector from "./detector.js";
|
|
9
|
+
/**
|
|
10
|
+
* Default {@link PhysicsAdapter} that wraps melonJS's native SAT-based
|
|
11
|
+
* physics. Owns the active body set, the {@link Detector}, gravity, and
|
|
12
|
+
* the simulation step. Returns the legacy {@link Body} class as its body
|
|
13
|
+
* handle so existing property-based game code (`body.vel.x = 5`,
|
|
14
|
+
* `body.isStatic = true`) keeps working unchanged.
|
|
15
|
+
*
|
|
16
|
+
* Instantiated by default during `Application` construction; user code
|
|
17
|
+
* only touches this directly when explicitly wiring it via
|
|
18
|
+
* `new Application(w, h, { physic: { adapter: new BuiltinAdapter() } })`.
|
|
19
|
+
* @category Physics
|
|
20
|
+
*/
|
|
21
|
+
export default class BuiltinAdapter implements PhysicsAdapter {
|
|
22
|
+
/**
|
|
23
|
+
* Short adapter identifier exposed as `world.physic`. Lets user code
|
|
24
|
+
* branch on the active physics implementation without importing the
|
|
25
|
+
* concrete adapter class.
|
|
26
|
+
*/
|
|
27
|
+
readonly physicLabel = "builtin";
|
|
28
|
+
/**
|
|
29
|
+
* Advertised capabilities; user code may branch on these.
|
|
30
|
+
*/
|
|
31
|
+
readonly capabilities: AdapterCapabilities;
|
|
32
|
+
/**
|
|
33
|
+
* World gravity. Mutate to change at runtime.
|
|
34
|
+
* @default <0, 0.98>
|
|
35
|
+
*/
|
|
36
|
+
gravity: Vector2d;
|
|
37
|
+
/**
|
|
38
|
+
* Active physics bodies in this simulation.
|
|
39
|
+
*/
|
|
40
|
+
readonly bodies: Set<Body>;
|
|
41
|
+
/**
|
|
42
|
+
* Collision detector instance, created in {@link init}.
|
|
43
|
+
*/
|
|
44
|
+
detector: Detector;
|
|
45
|
+
/**
|
|
46
|
+
* Back-reference to the owning world, set in {@link init}.
|
|
47
|
+
*/
|
|
48
|
+
private world;
|
|
49
|
+
constructor(options?: AdapterOptions);
|
|
50
|
+
init(world: World): void;
|
|
51
|
+
destroy(): void;
|
|
52
|
+
step(dt: number): void;
|
|
53
|
+
syncFromPhysics(): void;
|
|
54
|
+
addBody(renderable: Renderable, def: BodyDefinition): Body;
|
|
55
|
+
removeBody(renderable: Renderable): void;
|
|
56
|
+
updateShape(renderable: Renderable, shapes: BodyShape[]): void;
|
|
57
|
+
getVelocity(renderable: Renderable, out?: Vector2d): Vector2d;
|
|
58
|
+
setVelocity(renderable: Renderable, v: Vector2d): void;
|
|
59
|
+
applyForce(renderable: Renderable, force: Vector2d, point?: Vector2d): void;
|
|
60
|
+
applyImpulse(renderable: Renderable, impulse: Vector2d): void;
|
|
61
|
+
setPosition(renderable: Renderable, p: Vector2d): void;
|
|
62
|
+
setAngle(renderable: Renderable, angle: number): void;
|
|
63
|
+
getAngle(renderable: Renderable): number;
|
|
64
|
+
setAngularVelocity(renderable: Renderable, omega: number): void;
|
|
65
|
+
getAngularVelocity(renderable: Renderable): number;
|
|
66
|
+
applyTorque(renderable: Renderable, torque: number): void;
|
|
67
|
+
setStatic(renderable: Renderable, isStatic: boolean): void;
|
|
68
|
+
setGravityScale(renderable: Renderable, scale: number): void;
|
|
69
|
+
setFrictionAir(renderable: Renderable, friction: number | {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
}): void;
|
|
73
|
+
setMaxVelocity(renderable: Renderable, limit: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
}): void;
|
|
77
|
+
getMaxVelocity(renderable: Renderable): {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
};
|
|
81
|
+
setCollisionType(renderable: Renderable, type: number): void;
|
|
82
|
+
setCollisionMask(renderable: Renderable, mask: number): void;
|
|
83
|
+
setSensor(renderable: Renderable, isSensor: boolean): void;
|
|
84
|
+
getBodyAABB(renderable: Renderable, out: Bounds): Bounds | undefined;
|
|
85
|
+
getBodyShapes(renderable: Renderable): readonly BodyShape[];
|
|
86
|
+
isGrounded(renderable: Renderable): boolean;
|
|
87
|
+
raycast(from: Vector2d, to: Vector2d): RaycastHit | null;
|
|
88
|
+
queryAABB(rect: Rect): Renderable[];
|
|
89
|
+
applyGravity(body: Body): void;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=builtin-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-adapter.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/builtin-adapter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
* Pairs (key → [renderableA, renderableB]) that were colliding in
|
|
19
|
+
* the previous step. Diffed against `_frameSeen` at end of step
|
|
20
|
+
* to fire `onCollisionEnd` for pairs that just separated.
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
_activePairs: Map<any, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Pairs seen during the current step. Built up as the per-object
|
|
26
|
+
* `collisions()` calls run; consumed by `endFrame()`.
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
_frameSeen: Map<any, any>;
|
|
30
|
+
/**
|
|
31
|
+
* Two-slot pool of "symmetric view" objects passed to the new
|
|
32
|
+
* collision lifecycle handlers (`onCollisionStart` /
|
|
33
|
+
* `onCollisionActive` / `onCollisionEnd`). Each view carries the
|
|
34
|
+
* receiver-symmetric form: `a` = receiver, `b` = partner,
|
|
35
|
+
* `normal` = MTV of receiver, `depth` = penetration scalar,
|
|
36
|
+
* plus the SAT-legacy `overlapN` / `overlapV` / `overlap` fields
|
|
37
|
+
* flipped to match the same convention.
|
|
38
|
+
*
|
|
39
|
+
* Two slots are needed because both views may be live at the
|
|
40
|
+
* same time (one handler can dispatch into the other through
|
|
41
|
+
* world mutation). Slot 0 is used for the original-a-side
|
|
42
|
+
* dispatch, slot 1 for the original-b-side.
|
|
43
|
+
* @ignore
|
|
44
|
+
*/
|
|
45
|
+
_symViews: {
|
|
46
|
+
a: null;
|
|
47
|
+
b: null;
|
|
48
|
+
overlap: number;
|
|
49
|
+
overlapN: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
overlapV: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
normal: {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
};
|
|
61
|
+
depth: number;
|
|
62
|
+
}[];
|
|
63
|
+
/**
|
|
64
|
+
* Populate one of the pooled symmetric views from a SAT response.
|
|
65
|
+
* `flip=false` builds the view for `response.a`'s side (legacy
|
|
66
|
+
* fields kept as-is, `normal = -overlapN` = MTV of original a).
|
|
67
|
+
* `flip=true` builds it for `response.b`'s side: `a` / `b` swap,
|
|
68
|
+
* `overlapN` / `overlapV` negated, `normal = +overlapN` (the MTV
|
|
69
|
+
* of original b).
|
|
70
|
+
* @ignore
|
|
71
|
+
*/
|
|
72
|
+
_fillSymView(slot: any, satResponse: any, flip: any): {
|
|
73
|
+
a: null;
|
|
74
|
+
b: null;
|
|
75
|
+
overlap: number;
|
|
76
|
+
overlapN: {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
};
|
|
80
|
+
overlapV: {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
};
|
|
84
|
+
normal: {
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
};
|
|
88
|
+
depth: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Called by the adapter at the start of a physics step. Resets the
|
|
92
|
+
* "seen this frame" set so the end-of-step diff can fire
|
|
93
|
+
* `onCollisionEnd` for pairs that no longer overlap.
|
|
94
|
+
* @ignore
|
|
95
|
+
*/
|
|
96
|
+
beginFrame(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Called by the adapter at the end of a physics step. Diffs the
|
|
99
|
+
* "seen this frame" set against the previous-frame active pairs:
|
|
100
|
+
* - pairs in active but not seen → fire onCollisionEnd
|
|
101
|
+
* - swap active ← seen for the next step's diff
|
|
102
|
+
* @ignore
|
|
103
|
+
*/
|
|
104
|
+
endFrame(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Build a stable order-independent key for a pair of renderables,
|
|
107
|
+
* using their GUID. Returns undefined if either lacks a GUID (defensive
|
|
108
|
+
* — detached or pool-recycled objects mid-step).
|
|
109
|
+
* @ignore
|
|
110
|
+
*/
|
|
111
|
+
_pairKey(a: any, b: any): string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* determine if two objects should collide (based on both respective objects body collision mask and type).<br>
|
|
114
|
+
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
115
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
116
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
117
|
+
* @returns {boolean} true if they should collide, false otherwise
|
|
118
|
+
*/
|
|
119
|
+
shouldCollide(a: Renderable | Container | Entity | Sprite | NineSliceSprite, b: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* detect collision between two bodies.
|
|
122
|
+
* @param {Body} bodyA - a reference to body A.
|
|
123
|
+
* @param {Body} bodyB - a reference to body B.
|
|
124
|
+
* @returns {boolean} true if colliding
|
|
125
|
+
*/
|
|
126
|
+
collides(bodyA: Body, bodyB: Body, response?: ResponseObject): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* find all the collisions for the specified object using a broadphase algorithm
|
|
129
|
+
* @ignore
|
|
130
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision
|
|
131
|
+
* @returns {boolean} in case of collision, false otherwise
|
|
132
|
+
*/
|
|
133
|
+
collisions(objA: Renderable | Container | Entity | Sprite | NineSliceSprite): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Checks for object colliding with the given line
|
|
136
|
+
* @ignore
|
|
137
|
+
* @param {Line} line - line to be tested for collision
|
|
138
|
+
* @param {Array.<Renderable>} [result] - a user defined array that will be populated with intersecting physic objects.
|
|
139
|
+
* @returns {Array.<Renderable>} an array of intersecting physic objects
|
|
140
|
+
* @example
|
|
141
|
+
* // define a line accross the viewport
|
|
142
|
+
* let ray = new Line(
|
|
143
|
+
* // absolute position of the line
|
|
144
|
+
* 0, 0, [
|
|
145
|
+
* // starting point relative to the initial position
|
|
146
|
+
* new Vector2d(0, 0),
|
|
147
|
+
* // ending point
|
|
148
|
+
* new Vector2d(app.viewport.width, app.viewport.height)
|
|
149
|
+
* ]);
|
|
150
|
+
*
|
|
151
|
+
* // check for collition
|
|
152
|
+
* result = me.collision.rayCast(ray);
|
|
153
|
+
*
|
|
154
|
+
* if (result.length > 0) {
|
|
155
|
+
* // ...
|
|
156
|
+
* }
|
|
157
|
+
*/
|
|
158
|
+
rayCast(line: Line, result?: Array<Renderable>): Array<Renderable>;
|
|
159
|
+
}
|
|
160
|
+
import type Container from "../../renderable/container.js";
|
|
161
|
+
import ResponseObject from "../response.js";
|
|
162
|
+
import type Renderable from "../../renderable/renderable.js";
|
|
163
|
+
import type Entity from "../../renderable/entity/entity.js";
|
|
164
|
+
import type Sprite from "../../renderable/sprite.js";
|
|
165
|
+
import type NineSliceSprite from "../../renderable/nineslicesprite.js";
|
|
166
|
+
import type { Line } from "../../geometries/line.ts";
|
|
167
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/detector.js"],"names":[],"mappings":";AA4CA;;GAEG;AACH;IACC;;OAEG;IACH,mBAFW,SAAS,EA6DnB;IAzDA,iBAAkB;IAElB;;;;OAIG;IACH,UAFU,cAAc,CAEY;IAEpC;;;;;OAKG;IACH,4BAA6B;IAC7B;;;;OAIG;IACH,0BAA2B;IAC3B;;;;;;;;;;;;;;OAcG;IACH;;;;;;;;;;;;;;;;;QAmBC;IAGF;;;;;;;;OAQG;IACH;;;;;;;;;;;;;;;;;MA4BC;IAED;;;;;OAKG;IACH,mBAEC;IAED;;;;;;OAMG;IACH,iBA6BC;IAED;;;;;OAKG;IACH,6CAOC;IAED;;;;;;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,CAqLnB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,cArBW,IAAI,WACJ,KAAK,CAAE,UAAU,CAAC,GAChB,KAAK,CAAE,UAAU,CAAC,CAqC9B;CACD;2BA3dyB,+BAA+B;2BAhC9B,gBAAgB;4BAiChB,gCAAgC;wBAFpC,mCAAmC;wBAGnC,4BAA4B;iCACnB,qCAAqC;0BAC9C,0BAA0B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
/**
|
|
23
|
+
* Total number of objects in this subtree (this node's own
|
|
24
|
+
* `objects` plus every descendant's). Maintained by `insert`
|
|
25
|
+
* and `remove` so `isPrunable` / `hasChildren` are O(1) reads
|
|
26
|
+
* instead of O(tree-size) walks. Reset to 0 in `clear`.
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
_subtreeCount: number;
|
|
30
|
+
/**
|
|
31
|
+
* Root-only scratch array reused across `retrieve` calls to
|
|
32
|
+
* avoid allocating a fresh array per pointer event / per
|
|
33
|
+
* narrow-phase query. Only the root allocates one; recursive
|
|
34
|
+
* subnode calls receive the array via the `result` arg.
|
|
35
|
+
* @ignore
|
|
36
|
+
*/
|
|
37
|
+
_retrieveScratch: never[] | null;
|
|
38
|
+
split(): void;
|
|
39
|
+
getIndex(item: any): number;
|
|
40
|
+
/**
|
|
41
|
+
* Insert the given object container into the node.
|
|
42
|
+
* @param {Container} container - group of objects to be added
|
|
43
|
+
*/
|
|
44
|
+
insertContainer(container: Container): void;
|
|
45
|
+
/**
|
|
46
|
+
* Insert the given object into the node. If the node
|
|
47
|
+
* exceeds the capacity, it will split and add all
|
|
48
|
+
* objects to their corresponding subnodes.
|
|
49
|
+
* @param {object} item - object to be added
|
|
50
|
+
*/
|
|
51
|
+
insert(item: object): void;
|
|
52
|
+
/**
|
|
53
|
+
* Recursively remove the given container and its descendants from
|
|
54
|
+
* the quadtree. Mirrors `insertContainer` so the broadphase can be
|
|
55
|
+
* kept in sync when a subtree is detached via
|
|
56
|
+
* `Container.removeChildNow` between two `world.update()` rebuilds
|
|
57
|
+
* (pointer events fire async in that window and would otherwise
|
|
58
|
+
* hit destroyed renderables).
|
|
59
|
+
* @param {Container} container - group of objects to be removed
|
|
60
|
+
*/
|
|
61
|
+
removeContainer(container: Container): void;
|
|
62
|
+
/**
|
|
63
|
+
* Return all objects that could collide with the given object.
|
|
64
|
+
*
|
|
65
|
+
* **Re-entrancy contract:** when called with no explicit `result`
|
|
66
|
+
* argument, this method reuses a single root-level scratch array to
|
|
67
|
+
* avoid per-frame allocations. The returned reference is therefore
|
|
68
|
+
* **not safe to retain** past the next `retrieve()` call, AND it is
|
|
69
|
+
* **not safe to issue another scratch-mode `retrieve()` while iterating
|
|
70
|
+
* the previous result** — the second call clears the scratch and
|
|
71
|
+
* refills it, corrupting the outer iteration. In-engine callers
|
|
72
|
+
* (`pointerevent.ts`, `detector.js`) iterate synchronously and never
|
|
73
|
+
* recurse into `retrieve()`, so they're fine. User-facing portable
|
|
74
|
+
* APIs (`adapter.queryAABB`, `adapter.raycast`) pass their own array
|
|
75
|
+
* via the `result` parameter, which bypasses the scratch entirely
|
|
76
|
+
* and is safe to call from inside collision handlers.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} item - object to be checked against
|
|
79
|
+
* @param {object} [fn] - a sorting function for the returned array
|
|
80
|
+
* @param {object[]} [result] - optional caller-supplied result array.
|
|
81
|
+
* Pass an explicit (typically empty) array to sidestep the shared
|
|
82
|
+
* scratch — required for re-entrancy safety.
|
|
83
|
+
* @returns {object[]} array with all detected objects
|
|
84
|
+
*/
|
|
85
|
+
retrieve(item: object, fn?: object, result?: object[]): object[];
|
|
86
|
+
/**
|
|
87
|
+
* Remove the given item from the quadtree.
|
|
88
|
+
* (this function won't recalculate the impacted node)
|
|
89
|
+
* @param {object} item - object to be removed
|
|
90
|
+
* @returns {boolean} true if the item was found and removed.
|
|
91
|
+
*/
|
|
92
|
+
remove(item: object): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* return true if the node is prunable
|
|
95
|
+
* @returns {boolean} true if the node is prunable
|
|
96
|
+
*/
|
|
97
|
+
isPrunable(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* return true if the node has any children
|
|
100
|
+
* @returns {boolean} true if the node has any children
|
|
101
|
+
*/
|
|
102
|
+
hasChildren(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* clear the quadtree
|
|
105
|
+
* @param {Bounds} [bounds=this.bounds] - the bounds to be cleared
|
|
106
|
+
*/
|
|
107
|
+
clear(bounds?: Bounds): void;
|
|
108
|
+
}
|
|
109
|
+
import type World from "../world.js";
|
|
110
|
+
import type { Bounds } from "../bounds.ts";
|
|
111
|
+
import type Container from "../../renderable/container.js";
|
|
112
|
+
//# sourceMappingURL=quadtree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadtree.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/quadtree.js"],"names":[],"mappings":"AA2DA;;;;GAIG;AACH;IACC;;;;;;OAMG;IACH,mBANW,KAAK,UACL,MAAM,gBACN,MAAM,eACN,MAAM,UACN,MAAM,EA+BhB;IA5BA,aAAkB;IAClB,eAAoB;IAEpB,oBAA8B;IAC9B,mBAA4B;IAE5B,cAAkB;IAElB,eAAiB;IACjB,aAAe;IAEf;;;;;;OAMG;IACH,sBAAsB;IAEtB;;;;;;OAMG;IACH,iCAA+C;IAMhD,cA8DC;IAOD,4BA+CC;IAED;;;OAGG;IACH,2BAFW,SAAS,QA2BnB;IAED;;;;;OAKG;IACH,aAFW,MAAM,QA+ChB;IAED;;;;;;;;OAQG;IACH,2BAFW,SAAS,QAuBnB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,eAPW,MAAM,OACN,MAAM,WACN,MAAM,EAAE,GAGN,MAAM,EAAE,CAwCpB;IAED;;;;;OAKG;IACH,aAHW,MAAM,GACJ,OAAO,CAsEnB;IAED;;;OAGG;IACH,cAFa,OAAO,CAMnB;IAED;;;OAGG;IACH,eAFa,OAAO,CAOnB;IAED;;;OAGG;IACH,eAFW,MAAM,QAwBhB;CACD;uBA5gBqB,aAAa;4BAEV,cAAc;2BADb,+BAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raycast.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/raycast.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AA8KrC,wBAAgB,YAAY,CAC3B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACT,UAAU,EAAE,CA4Gd"}
|
|
@@ -46,11 +46,11 @@ export function testPolygonEllipse(a: Renderable | Container | Entity | Sprite |
|
|
|
46
46
|
* @returns {boolean} true if they intersect, false if they don't.
|
|
47
47
|
*/
|
|
48
48
|
export function testEllipsePolygon(a: Renderable | Container | Entity | Sprite | NineSliceSprite, ellipseA: Ellipse, b: Renderable | Container | Entity | Sprite | NineSliceSprite, polyB: Polygon, response?: Response | undefined): boolean;
|
|
49
|
-
import type Renderable from "
|
|
50
|
-
import type Container from "
|
|
51
|
-
import type Entity from "
|
|
52
|
-
import type Sprite from "
|
|
53
|
-
import type NineSliceSprite from "
|
|
54
|
-
import type { Polygon } from "
|
|
55
|
-
import type { Ellipse } from "
|
|
49
|
+
import type Renderable from "../../renderable/renderable.js";
|
|
50
|
+
import type Container from "../../renderable/container.js";
|
|
51
|
+
import type Entity from "../../renderable/entity/entity.js";
|
|
52
|
+
import type Sprite from "../../renderable/sprite.js";
|
|
53
|
+
import type NineSliceSprite from "../../renderable/nineslicesprite.js";
|
|
54
|
+
import type { Polygon } from "../../geometries/polygon.ts";
|
|
55
|
+
import type { Ellipse } from "../../geometries/ellipse.ts";
|
|
56
56
|
//# sourceMappingURL=sat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sat.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/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;AACH,sCAPW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,SAClD,OAAO,KACP,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,YAClD,OAAO,aACP,QAAQ,YAAC,GACP,OAAO,CAsKnB;AAED;;;;;;;;;;;;GAYG;AACH,sCARW,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,YAClD,OAAO,KACP,UAAU,GAAC,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,eAAe,SAClD,OAAO,aACP,QAAQ,YAAC,GAEP,OAAO,CAiBnB;4BAvhB0B,gCAAgC;2BADjC,+BAA+B;wBADlC,mCAAmC;wBAGnC,4BAA4B;iCACnB,qCAAqC;6BAC3C,6BAA6B;6BAC7B,6BAA6B"}
|
package/build/physics/world.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import Application from "./../application/application.ts";
|
|
3
|
-
* @import Body from "./body.js";
|
|
4
|
-
*/
|
|
5
1
|
/**
|
|
6
2
|
* an object representing the physic world, and responsible for managing and updating all children and physics
|
|
7
3
|
* @category Container
|
|
@@ -12,20 +8,38 @@ export default class World extends Container {
|
|
|
12
8
|
* @param {number} [y=0] - position of the container (accessible via the inherited pos.y property)
|
|
13
9
|
* @param {number} [width=Infinity] - width of the world container
|
|
14
10
|
* @param {number} [height=Infinity] - height of the world container
|
|
11
|
+
* @param {PhysicsAdapter} [adapter] - physics adapter to use; defaults to a new {@link BuiltinAdapter} instance
|
|
15
12
|
*/
|
|
16
|
-
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
13
|
+
constructor(x?: number, y?: number, width?: number, height?: number, adapter?: PhysicsAdapter);
|
|
17
14
|
/**
|
|
18
15
|
* the application (game) this physic world belong to
|
|
19
16
|
* @type {Application}
|
|
20
17
|
*/
|
|
21
18
|
app: Application;
|
|
22
19
|
/**
|
|
23
|
-
* the
|
|
20
|
+
* Identifier of the active physics adapter, taken from the
|
|
21
|
+
* adapter's `physicLabel` field at `Application` construction —
|
|
22
|
+
* `"builtin"` (default — `BuiltinAdapter`), `"matter"`
|
|
23
|
+
* (`@melonjs/matter-adapter`), or a third-party label.
|
|
24
|
+
* The reserved value `"none"` is set when physics is disabled via
|
|
25
|
+
* `physic: "none"` in `ApplicationSettings`; `World.step` skips
|
|
26
|
+
* the simulation entirely under that label, and the rest of the
|
|
27
|
+
* world container behaves like a pure scene graph.
|
|
28
|
+
*
|
|
29
|
+
* User code can branch on the value without importing the
|
|
30
|
+
* adapter class:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* if (app.world.physic === "matter") {
|
|
34
|
+
* // matter-only setup (constraints, native queries, …)
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
24
37
|
* @see ApplicationSettings.physic
|
|
38
|
+
* @see PhysicsAdapter.physicLabel
|
|
25
39
|
* @type {string}
|
|
26
40
|
* @default "builtin"
|
|
27
41
|
* @example
|
|
28
|
-
* // disable
|
|
42
|
+
* // disable physics entirely
|
|
29
43
|
* app.world.physic = "none";
|
|
30
44
|
*/
|
|
31
45
|
physic: string;
|
|
@@ -36,12 +50,6 @@ export default class World extends Container {
|
|
|
36
50
|
* @see timer.maxfps
|
|
37
51
|
*/
|
|
38
52
|
fps: number;
|
|
39
|
-
/**
|
|
40
|
-
* world gravity
|
|
41
|
-
* @type {Vector2d}
|
|
42
|
-
* @default <0,0.98>
|
|
43
|
-
*/
|
|
44
|
-
gravity: Vector2d;
|
|
45
53
|
/**
|
|
46
54
|
* Enabled pre-rendering for all tile layers. <br>
|
|
47
55
|
* If false layers are rendered dynamically, if true layers are first fully rendered into an offscreen canvas.<br>
|
|
@@ -52,22 +60,63 @@ export default class World extends Container {
|
|
|
52
60
|
*/
|
|
53
61
|
preRender: boolean;
|
|
54
62
|
/**
|
|
55
|
-
* the
|
|
56
|
-
*
|
|
63
|
+
* Enable the WebGL2 procedural shader path for orthogonal tile
|
|
64
|
+
* layers. When `true` (default), eligible layers render via a
|
|
65
|
+
* single quad per tileset + a fragment shader doing per-pixel GID
|
|
66
|
+
* lookup — bypassing the per-tile drawImage loop entirely.
|
|
67
|
+
* Supported features on the shader path: animated tiles, all
|
|
68
|
+
* three flip bits (H/V/AD), per-layer opacity/tint/blend mode,
|
|
69
|
+
* and oversized bottom-aligned tiles up to 4 cells of overflow.
|
|
70
|
+
* Layers that don't qualify (Canvas/WebGL1, non-orthogonal,
|
|
71
|
+
* collection-of-image tilesets, non-zero `tileoffset`, or tile
|
|
72
|
+
* overflow beyond the shader's 4-cell limit) fall back to the
|
|
73
|
+
* legacy path automatically. Set to `false` to disable globally.
|
|
74
|
+
* @type {boolean}
|
|
75
|
+
* @default true
|
|
57
76
|
*/
|
|
58
|
-
|
|
77
|
+
gpuTilemap: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* the physics adapter driving this world. Defaults to a
|
|
80
|
+
* {@link BuiltinAdapter} wrapping the engine's native SAT-based
|
|
81
|
+
* physics. Override at `Application` construction time via
|
|
82
|
+
* `settings.physic.adapter`. Cannot be swapped at runtime.
|
|
83
|
+
* @type {PhysicsAdapter}
|
|
84
|
+
*/
|
|
85
|
+
adapter: PhysicsAdapter;
|
|
59
86
|
/**
|
|
60
87
|
* the instance of the game world quadtree used for broadphase (used by the builtin physic and pointer event implementation)
|
|
61
88
|
* @type {QuadTree}
|
|
62
89
|
*/
|
|
63
90
|
broadphase: QuadTree;
|
|
64
91
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
92
|
+
* Active physics bodies in this simulation. Backed by the active
|
|
93
|
+
* adapter; mutating this set directly is no longer the recommended
|
|
94
|
+
* pattern — use `world.adapter.addBody(...)` / `removeBody(...)`.
|
|
95
|
+
*
|
|
96
|
+
* Adapters that don't expose a native `bodies` Set (e.g. third-party
|
|
97
|
+
* integrations that own their own body storage) cause this getter
|
|
98
|
+
* to return a frozen empty Set, so any `world.bodies.add(...)`
|
|
99
|
+
* attempt throws `TypeError` instead of silently mutating a
|
|
100
|
+
* throwaway.
|
|
101
|
+
* @returns {Set<Body>}
|
|
102
|
+
*/
|
|
103
|
+
get bodies(): Set<Body>;
|
|
104
|
+
set gravity(v: Vector2d);
|
|
105
|
+
/**
|
|
106
|
+
* world gravity. Mutate to change at runtime.
|
|
107
|
+
* @returns {Vector2d}
|
|
108
|
+
*/
|
|
109
|
+
get gravity(): Vector2d;
|
|
110
|
+
/**
|
|
111
|
+
* the collision detector instance used by this world instance.
|
|
112
|
+
* Available only when the active adapter is {@link BuiltinAdapter}.
|
|
113
|
+
* @returns {Detector | undefined}
|
|
67
114
|
*/
|
|
68
|
-
detector: Detector;
|
|
115
|
+
get detector(): Detector | undefined;
|
|
69
116
|
/**
|
|
70
|
-
* Add a physic body to the game world
|
|
117
|
+
* Add a physic body to the game world. Legacy API for code that
|
|
118
|
+
* constructed `new Body(...)` directly and now wants to register it
|
|
119
|
+
* with the active physics adapter.
|
|
71
120
|
* @see Container.addChild
|
|
72
121
|
* @param {Body} body
|
|
73
122
|
* @returns {World} this game world
|
|
@@ -81,21 +130,23 @@ export default class World extends Container {
|
|
|
81
130
|
*/
|
|
82
131
|
removeBody(body: Body): World;
|
|
83
132
|
/**
|
|
84
|
-
* Apply gravity to the given body
|
|
133
|
+
* Apply gravity to the given body. Backward-compat shim; the actual
|
|
134
|
+
* simulation runs through the active adapter.
|
|
85
135
|
* @private
|
|
86
136
|
* @param {Body} body
|
|
87
137
|
*/
|
|
88
138
|
private bodyApplyGravity;
|
|
89
139
|
/**
|
|
90
|
-
* update the
|
|
140
|
+
* update the physics simulation by one step (called by the game world update method)
|
|
91
141
|
* @param {number} dt - the time passed since the last frame update
|
|
92
142
|
*/
|
|
93
143
|
step(dt: number): void;
|
|
94
144
|
}
|
|
95
145
|
import Container from "../renderable/container.js";
|
|
96
146
|
import type Application from "./../application/application.ts";
|
|
97
|
-
import {
|
|
98
|
-
import
|
|
99
|
-
import
|
|
100
|
-
import
|
|
147
|
+
import type { PhysicsAdapter } from "./adapter.ts";
|
|
148
|
+
import QuadTree from "./builtin/quadtree.js";
|
|
149
|
+
import type Body from "./builtin/body.js";
|
|
150
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
151
|
+
import type Detector from "./builtin/detector.js";
|
|
101
152
|
//# sourceMappingURL=world.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/physics/world.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/physics/world.js"],"names":[],"mappings":"AA8BA;;;GAGG;AACH;IACC;;;;;;OAMG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,YACN,cAAc,EAoHxB;IAlGA;;;OAGG;IACH,KAFU,WAAW,CAED;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QANU,MAAM,CAMO;IAEvB;;;;;OAKG;IACH,YAAa;IAEb;;;;;;;OAOG;IACH,WAHU,OAAO,CAGK;IAEtB;;;;;;;;;;;;;;OAcG;IACH,YAHU,OAAO,CAGK;IAEtB;;;;;;OAMG;IACH,SAFU,cAAc,CAEsB;IAG9C;;;OAGG;IACH,YAFU,QAAQ,CAOjB;IAYF;;;;;;;;;;;OAWG;IACH,cAFa,GAAG,CAAC,IAAI,CAAC,CAOrB;IASD,eALa,QAAQ,EAOpB;IATD;;;OAGG;IACH,eAFa,QAAQ,CAIpB;IAKD;;;;OAIG;IACH,gBAFa,QAAQ,GAAG,SAAS,CAIhC;IAsCD;;;;;;;OAOG;IACH,cAHW,IAAI,GACF,KAAK,CASjB;IAED;;;;;OAKG;IACH,iBAHW,IAAI,GACF,KAAK,CASjB;IAED;;;;;OAKG;IACH,yBAIC;IAuBD;;;OAGG;IACH,SAFW,MAAM,QAWhB;CACD;sBAvTqB,4BAA4B;6BAatB,iCAAiC;oCAI1B,cAAc;qBAR5B,uBAAuB;sBAKvB,mBAAmB;8BAEX,qBAAqB;0BADzB,uBAAuB"}
|
|
@@ -12,7 +12,13 @@ export default class Collectable extends Sprite {
|
|
|
12
12
|
name: any;
|
|
13
13
|
type: any;
|
|
14
14
|
id: any;
|
|
15
|
-
|
|
15
|
+
bodyDef: {
|
|
16
|
+
type: string;
|
|
17
|
+
shapes: any[];
|
|
18
|
+
collisionType: number;
|
|
19
|
+
collisionMask: number;
|
|
20
|
+
isSensor: boolean;
|
|
21
|
+
};
|
|
16
22
|
}
|
|
17
23
|
import Sprite from "./sprite.js";
|
|
18
24
|
//# sourceMappingURL=collectable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectable.d.ts","sourceRoot":"","sources":["../../src/renderable/collectable.js"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -104,11 +104,6 @@ export default class Container extends Renderable {
|
|
|
104
104
|
* this.backgroundColor.setColor(255, 0, 0);
|
|
105
105
|
*/
|
|
106
106
|
backgroundColor: Color;
|
|
107
|
-
/**
|
|
108
|
-
* Used by the debug panel plugin
|
|
109
|
-
* @ignore
|
|
110
|
-
*/
|
|
111
|
-
drawCount: number;
|
|
112
107
|
set sortOn(value: string);
|
|
113
108
|
/**
|
|
114
109
|
* The property of the child object that should be used to sort on this container.
|
|
@@ -260,10 +255,6 @@ export default class Container extends Renderable {
|
|
|
260
255
|
* @returns {Container} root container
|
|
261
256
|
*/
|
|
262
257
|
getRootAncestor(): Container;
|
|
263
|
-
/**
|
|
264
|
-
* @ignore
|
|
265
|
-
*/
|
|
266
|
-
onActivateEvent(): void;
|
|
267
258
|
/**
|
|
268
259
|
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
|
|
269
260
|
* if the given child implements an onDeactivateEvent() method, that method will be called once the child is removed from this container.
|
|
@@ -311,10 +302,6 @@ export default class Container extends Renderable {
|
|
|
311
302
|
* @param {boolean} [recursive=false] - recursively sort all containers if true
|
|
312
303
|
*/
|
|
313
304
|
sort(recursive?: boolean): void;
|
|
314
|
-
/**
|
|
315
|
-
* @ignore
|
|
316
|
-
*/
|
|
317
|
-
onDeactivateEvent(): void;
|
|
318
305
|
/**
|
|
319
306
|
* Z Sorting function
|
|
320
307
|
* @ignore
|