plinkit 1.0.0-dev.0 → 1.0.0-dev.2
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 +67 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +35 -1
- package/dist/index.es.js +1546 -1347
- package/dist/plinkit.umd.js +4 -4
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,151 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Be = (d, E) => () => (E || (d((E = { exports: {} }).exports, E), d = null), E.exports), Ee = 35, Ae = 24, Ie = 0.08, Le = 6, Re = 0.85, pe = 0.7, ke = 0.16, be = 0.92, De = 256, Ue = 1e3, Fe = class {
|
|
2
|
+
ctx = null;
|
|
3
|
+
masterGain = null;
|
|
4
|
+
buffers = /* @__PURE__ */ new Map();
|
|
5
|
+
lastHitByBall = /* @__PURE__ */ new Map();
|
|
6
|
+
activePegVoices = 0;
|
|
7
|
+
muted;
|
|
8
|
+
volume;
|
|
9
|
+
destroyed = !1;
|
|
10
|
+
unlockedOnce = !1;
|
|
11
|
+
pendingUiTap = !1;
|
|
12
|
+
gestureCleanup = null;
|
|
13
|
+
visibilityCleanup = null;
|
|
14
|
+
config;
|
|
15
|
+
constructor(d) {
|
|
16
|
+
this.config = d, this.muted = d.muted, this.volume = me(d.masterVolume), this.installGestureUnlock(), this.installVisibilityHandler();
|
|
17
|
+
}
|
|
18
|
+
setMuted(d) {
|
|
19
|
+
this.muted = d, this.masterGain && (this.masterGain.gain.value = d ? 0 : this.volume), d || this.tryUnlock();
|
|
20
|
+
}
|
|
21
|
+
isMuted() {
|
|
22
|
+
return this.muted;
|
|
23
|
+
}
|
|
24
|
+
setVolume(d) {
|
|
25
|
+
this.volume = me(d), this.masterGain && !this.muted && (this.masterGain.gain.value = this.volume);
|
|
26
|
+
}
|
|
27
|
+
resume() {
|
|
28
|
+
this.tryUnlock();
|
|
29
|
+
}
|
|
30
|
+
playPegHit(d, E) {
|
|
31
|
+
if (this.destroyed || this.muted || !this.unlockedOnce) return;
|
|
32
|
+
const T = this.ctx;
|
|
33
|
+
if (!T) return;
|
|
34
|
+
const A = T.currentTime * 1e3, f = this.lastHitByBall.get(d);
|
|
35
|
+
if (f !== void 0 && A - f < Ee || (this.lastHitByBall.set(d, A), this.maybeCleanupLastHits(A), this.activePegVoices >= Ae)) return;
|
|
36
|
+
const e = Math.max(Ie, Math.min(1, E / Le));
|
|
37
|
+
this.playSample("peg", e, !0);
|
|
38
|
+
}
|
|
39
|
+
playBucketHit() {
|
|
40
|
+
this.playSample("bucket", Re, !1);
|
|
41
|
+
}
|
|
42
|
+
playUiTap() {
|
|
43
|
+
if (!(this.destroyed || this.muted)) {
|
|
44
|
+
if (this.ensureContext(), this.unlockedOnce) {
|
|
45
|
+
this.playSample("uiTap", pe, !1);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.pendingUiTap = !0, this.tryUnlock();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
playSample(d, E, T) {
|
|
52
|
+
if (this.destroyed || this.muted || !this.unlockedOnce) return;
|
|
53
|
+
const A = this.ctx, f = this.masterGain;
|
|
54
|
+
if (!A || !f) return;
|
|
55
|
+
const e = this.buffers.get(d);
|
|
56
|
+
if (!e) return;
|
|
57
|
+
const o = A.createBufferSource();
|
|
58
|
+
o.buffer = e, o.playbackRate.value = be + Math.random() * ke;
|
|
59
|
+
const a = A.createGain();
|
|
60
|
+
a.gain.value = E, o.connect(a), a.connect(f), T && (this.activePegVoices += 1), o.onended = () => {
|
|
61
|
+
T && (this.activePegVoices = Math.max(0, this.activePegVoices - 1)), o.disconnect(), a.disconnect();
|
|
62
|
+
}, o.start();
|
|
63
|
+
}
|
|
64
|
+
destroy() {
|
|
65
|
+
this.destroyed || (this.destroyed = !0, this.gestureCleanup?.(), this.gestureCleanup = null, this.visibilityCleanup?.(), this.visibilityCleanup = null, this.buffers.clear(), this.lastHitByBall.clear(), this.ctx && (this.ctx.close().catch(ae), this.ctx = null, this.masterGain = null));
|
|
66
|
+
}
|
|
67
|
+
ensureContext() {
|
|
68
|
+
if (this.destroyed || this.ctx || typeof window > "u") return;
|
|
69
|
+
const d = window.AudioContext ?? window.webkitAudioContext;
|
|
70
|
+
d && (this.ctx = new d(), this.masterGain = this.ctx.createGain(), this.masterGain.gain.value = this.muted ? 0 : this.volume, this.masterGain.connect(this.ctx.destination), this.loadBuffers());
|
|
71
|
+
}
|
|
72
|
+
tryUnlock() {
|
|
73
|
+
if (this.destroyed) return;
|
|
74
|
+
this.ensureContext();
|
|
75
|
+
const d = this.ctx;
|
|
76
|
+
if (d) {
|
|
77
|
+
if (d.state === "running") {
|
|
78
|
+
this.markUnlocked();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
d.resume().then(() => this.markUnlocked()).catch(ae);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
markUnlocked() {
|
|
85
|
+
this.destroyed || this.unlockedOnce || (this.unlockedOnce = !0, this.playSilentPing(), this.gestureCleanup?.(), this.gestureCleanup = null, this.pendingUiTap && (this.pendingUiTap = !1, this.playSample("uiTap", pe, !1)));
|
|
86
|
+
}
|
|
87
|
+
playSilentPing() {
|
|
88
|
+
const d = this.ctx;
|
|
89
|
+
if (d)
|
|
90
|
+
try {
|
|
91
|
+
const E = d.createBuffer(1, 1, Math.max(22050, d.sampleRate)), T = d.createBufferSource();
|
|
92
|
+
T.buffer = E;
|
|
93
|
+
const A = d.createGain();
|
|
94
|
+
A.gain.value = 1e-5, T.connect(A), A.connect(d.destination);
|
|
95
|
+
try {
|
|
96
|
+
T.start(0);
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
T.stop(0);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
installGestureUnlock() {
|
|
107
|
+
if (typeof window > "u") return;
|
|
108
|
+
const d = {
|
|
109
|
+
passive: !0,
|
|
110
|
+
capture: !0
|
|
111
|
+
}, E = !0, T = () => this.tryUnlock();
|
|
112
|
+
window.addEventListener("pointerdown", T, d), window.addEventListener("pointerup", T, d), window.addEventListener("touchstart", T, d), window.addEventListener("touchend", T, d), window.addEventListener("keydown", T, E), this.gestureCleanup = () => {
|
|
113
|
+
window.removeEventListener("pointerdown", T, d), window.removeEventListener("pointerup", T, d), window.removeEventListener("touchstart", T, d), window.removeEventListener("touchend", T, d), window.removeEventListener("keydown", T, E);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
installVisibilityHandler() {
|
|
117
|
+
if (typeof document > "u") return;
|
|
118
|
+
const d = () => {
|
|
119
|
+
this.destroyed || document.hidden || this.unlockedOnce && this.ctx?.resume().catch(ae);
|
|
120
|
+
};
|
|
121
|
+
document.addEventListener("visibilitychange", d), this.visibilityCleanup = () => document.removeEventListener("visibilitychange", d);
|
|
122
|
+
}
|
|
123
|
+
async loadBuffers() {
|
|
124
|
+
const d = [];
|
|
125
|
+
this.config.pegHitUrl && d.push(this.loadBuffer("peg", this.config.pegHitUrl)), this.config.bucketHitUrl && d.push(this.loadBuffer("bucket", this.config.bucketHitUrl)), this.config.uiTapUrl && d.push(this.loadBuffer("uiTap", this.config.uiTapUrl)), await Promise.allSettled(d);
|
|
126
|
+
}
|
|
127
|
+
async loadBuffer(d, E) {
|
|
128
|
+
const T = this.ctx;
|
|
129
|
+
if (T)
|
|
130
|
+
try {
|
|
131
|
+
const A = await fetch(E);
|
|
132
|
+
if (!A.ok) return;
|
|
133
|
+
const f = await A.arrayBuffer(), e = await T.decodeAudioData(f);
|
|
134
|
+
this.destroyed || this.buffers.set(d, e);
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
maybeCleanupLastHits(d) {
|
|
139
|
+
if (!(this.lastHitByBall.size <= De))
|
|
140
|
+
for (const [E, T] of this.lastHitByBall) d - T > Ue && this.lastHitByBall.delete(E);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
function me(d) {
|
|
144
|
+
return !Number.isFinite(d) || d < 0 ? 0 : d > 1 ? 1 : d;
|
|
145
|
+
}
|
|
146
|
+
function ae() {
|
|
147
|
+
}
|
|
148
|
+
var Oe = class {
|
|
2
149
|
rafId = null;
|
|
3
150
|
step;
|
|
4
151
|
constructor(d) {
|
|
@@ -15,321 +162,321 @@ var Ce = (d, E) => () => (E || (d((E = { exports: {} }).exports, E), d = null),
|
|
|
15
162
|
this.rafId !== null && (window.cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
16
163
|
}
|
|
17
164
|
};
|
|
18
|
-
function
|
|
19
|
-
const
|
|
165
|
+
function Se(d, E) {
|
|
166
|
+
const T = d.bottomPegCount - d.topPegCount + 1, A = d.radius + d.sidePaddingPx, f = (E - A * 2) / Math.max(d.bottomPegCount - 1, 1);
|
|
20
167
|
return {
|
|
21
|
-
rows:
|
|
22
|
-
sidePadding:
|
|
23
|
-
baseSpacing:
|
|
24
|
-
targetVerticalStep:
|
|
168
|
+
rows: T,
|
|
169
|
+
sidePadding: A,
|
|
170
|
+
baseSpacing: f,
|
|
171
|
+
targetVerticalStep: f * d.verticalStepRatio
|
|
25
172
|
};
|
|
26
173
|
}
|
|
27
|
-
function
|
|
28
|
-
const { width: E, height:
|
|
29
|
-
if (d.bottomPegCount <
|
|
30
|
-
const
|
|
31
|
-
for (let
|
|
32
|
-
const t =
|
|
33
|
-
|
|
34
|
-
row:
|
|
174
|
+
function He(d) {
|
|
175
|
+
const { width: E, height: T, topPegCount: A } = d;
|
|
176
|
+
if (d.bottomPegCount < A) throw new Error("bottomPegCount must be greater than or equal to topPegCount");
|
|
177
|
+
const f = Se(d, E), e = E * 0.5, o = d.topPaddingPx, a = Math.max(o + 60, T - d.bottomPaddingPx), r = f.rows > 1 ? (a - o) / (f.rows - 1) : 0, c = Math.min(f.targetVerticalStep, r), n = a - c * Math.max(f.rows - 1, 0), h = [];
|
|
178
|
+
for (let l = 0; l < f.rows; l++) {
|
|
179
|
+
const t = A + l, i = n + l * c, s = (t - 1) * f.baseSpacing, u = e - s * 0.5;
|
|
180
|
+
h.push({
|
|
181
|
+
row: l,
|
|
35
182
|
count: t,
|
|
36
183
|
y: i,
|
|
37
|
-
startX:
|
|
184
|
+
startX: u,
|
|
38
185
|
rowWidth: s,
|
|
39
|
-
leftX:
|
|
40
|
-
rightX:
|
|
186
|
+
leftX: u,
|
|
187
|
+
rightX: u + s
|
|
41
188
|
});
|
|
42
189
|
}
|
|
43
190
|
return {
|
|
44
|
-
rows:
|
|
191
|
+
rows: f.rows,
|
|
45
192
|
center: e,
|
|
46
|
-
minTopY:
|
|
193
|
+
minTopY: o,
|
|
47
194
|
bottomY: a,
|
|
48
|
-
sidePadding:
|
|
49
|
-
baseSpacing:
|
|
50
|
-
verticalStep:
|
|
195
|
+
sidePadding: f.sidePadding,
|
|
196
|
+
baseSpacing: f.baseSpacing,
|
|
197
|
+
verticalStep: c,
|
|
51
198
|
startY: n,
|
|
52
|
-
rowAnchors:
|
|
199
|
+
rowAnchors: h
|
|
53
200
|
};
|
|
54
201
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
for (const
|
|
58
|
-
x:
|
|
59
|
-
y:
|
|
202
|
+
function Ve(d, E) {
|
|
203
|
+
const T = [];
|
|
204
|
+
for (const A of d.rowAnchors) for (let f = 0; f < A.count; f++) T.push({
|
|
205
|
+
x: A.startX + f * d.baseSpacing,
|
|
206
|
+
y: A.y,
|
|
60
207
|
radius: E
|
|
61
208
|
});
|
|
62
|
-
return
|
|
209
|
+
return T;
|
|
63
210
|
}
|
|
64
|
-
function
|
|
211
|
+
function Ne(d, E, T) {
|
|
65
212
|
if (d.rows < 2) return [];
|
|
66
|
-
const
|
|
67
|
-
for (let t = 1; t <=
|
|
68
|
-
const i = d.startY - t *
|
|
69
|
-
|
|
213
|
+
const A = [], f = (T.spread - 1) * d.baseSpacing, e = (t) => t < d.center ? t - f : t > d.center ? t + f : t, o = d.rowAnchors[0], a = o.leftX, r = o.rightX, c = d.startY - d.minTopY, n = E * 2.5, h = Math.min(d.verticalStep, Math.max(n, c / 3)), l = c >= n ? Math.min(3, Math.floor(c / h)) : 0;
|
|
214
|
+
for (let t = 1; t <= l; t++) {
|
|
215
|
+
const i = d.startY - t * h + T.yOffset, s = a - t * d.baseSpacing * 0.5, u = r + t * d.baseSpacing * 0.5;
|
|
216
|
+
A.push({
|
|
70
217
|
x: e(s),
|
|
71
218
|
y: i,
|
|
72
219
|
radius: E
|
|
73
220
|
}, {
|
|
74
|
-
x: e(
|
|
221
|
+
x: e(u),
|
|
75
222
|
y: i,
|
|
76
223
|
radius: E
|
|
77
224
|
});
|
|
78
225
|
}
|
|
79
|
-
for (let t = 0; t <
|
|
80
|
-
const i = d.startY - t *
|
|
81
|
-
|
|
82
|
-
x: e((
|
|
83
|
-
y: (i + s) / 2 +
|
|
226
|
+
for (let t = 0; t < l; t++) {
|
|
227
|
+
const i = d.startY - t * h, s = d.startY - (t + 1) * h, u = a - t * d.baseSpacing * 0.5, m = a - (t + 1) * d.baseSpacing * 0.5, x = r + t * d.baseSpacing * 0.5, P = r + (t + 1) * d.baseSpacing * 0.5;
|
|
228
|
+
A.push({
|
|
229
|
+
x: e((u + m) / 2),
|
|
230
|
+
y: (i + s) / 2 + T.yOffset,
|
|
84
231
|
radius: E
|
|
85
232
|
}, {
|
|
86
233
|
x: e((x + P) / 2),
|
|
87
|
-
y: (i + s) / 2 +
|
|
234
|
+
y: (i + s) / 2 + T.yOffset,
|
|
88
235
|
radius: E
|
|
89
236
|
});
|
|
90
237
|
}
|
|
91
238
|
for (let t = 0; t < d.rows - 1; t++) {
|
|
92
|
-
const i = d.rowAnchors[t], s = d.rowAnchors[t + 1],
|
|
93
|
-
|
|
239
|
+
const i = d.rowAnchors[t], s = d.rowAnchors[t + 1], u = (i.y + s.y) / 2 + T.yOffset;
|
|
240
|
+
A.push({
|
|
94
241
|
x: e((i.leftX + s.leftX) / 2),
|
|
95
|
-
y:
|
|
242
|
+
y: u,
|
|
96
243
|
radius: E
|
|
97
244
|
}, {
|
|
98
245
|
x: e((i.rightX + s.rightX) / 2),
|
|
99
|
-
y:
|
|
246
|
+
y: u,
|
|
100
247
|
radius: E
|
|
101
248
|
});
|
|
102
249
|
}
|
|
103
|
-
return
|
|
250
|
+
return A;
|
|
104
251
|
}
|
|
105
|
-
var
|
|
106
|
-
function
|
|
107
|
-
const { mainPegs: E, ballRadius:
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const { rows: e, baseSpacing:
|
|
252
|
+
var We = -1, Ge = 8;
|
|
253
|
+
function ze(d) {
|
|
254
|
+
const { mainPegs: E, ballRadius: T, heightPolicy: A } = d;
|
|
255
|
+
if (Ke(A), $e(E), !Number.isFinite(T) || T <= 0) throw new Error("ballRadius must be greater than 0");
|
|
256
|
+
const f = Se(E, 600);
|
|
257
|
+
if (f.baseSpacing <= 0) throw new Error("mainPegs produce non-positive base spacing; reduce sidePaddingPx or peg counts");
|
|
258
|
+
const { rows: e, baseSpacing: o, targetVerticalStep: a } = f, r = a * Math.max(e - 1, 0), c = A.topPaddingPx, n = a * 2, h = T * 2 + Ge, l = E.radius + T + We, t = Math.max(A.bottomPaddingPx, l + h);
|
|
112
259
|
return {
|
|
113
|
-
worldHeight:
|
|
260
|
+
worldHeight: c + n + r + t,
|
|
114
261
|
resolvedMainPegs: {
|
|
115
262
|
...E,
|
|
116
|
-
topPaddingPx:
|
|
263
|
+
topPaddingPx: c,
|
|
117
264
|
bottomPaddingPx: t
|
|
118
265
|
},
|
|
119
266
|
rows: e,
|
|
120
|
-
baseSpacing:
|
|
267
|
+
baseSpacing: o,
|
|
121
268
|
verticalStep: a,
|
|
122
269
|
requiredBottomPaddingPx: t
|
|
123
270
|
};
|
|
124
271
|
}
|
|
125
|
-
function
|
|
126
|
-
const { parentWidthPx: E, viewport:
|
|
127
|
-
if (
|
|
128
|
-
if (!Number.isFinite(
|
|
129
|
-
const
|
|
272
|
+
function Xe(d) {
|
|
273
|
+
const { parentWidthPx: E, viewport: T, worldHeight: A } = d;
|
|
274
|
+
if (Ye(T), !Number.isFinite(E) || E <= 0) throw new Error("Parent width must be greater than 0");
|
|
275
|
+
if (!Number.isFinite(A) || A <= 0) throw new Error("World height must be greater than 0");
|
|
276
|
+
const f = E;
|
|
130
277
|
return {
|
|
131
|
-
displayWidth:
|
|
132
|
-
displayHeight:
|
|
133
|
-
worldScale:
|
|
278
|
+
displayWidth: f,
|
|
279
|
+
displayHeight: f * (A / 600),
|
|
280
|
+
worldScale: f / 600
|
|
134
281
|
};
|
|
135
282
|
}
|
|
136
|
-
function
|
|
283
|
+
function Ke(d) {
|
|
137
284
|
if (!Number.isFinite(d.topPaddingPx) || d.topPaddingPx < 0) throw new Error("viewport.heightPolicy.topPaddingPx must be >= 0");
|
|
138
285
|
if (!Number.isFinite(d.bottomPaddingPx) || d.bottomPaddingPx < 0) throw new Error("viewport.heightPolicy.bottomPaddingPx must be >= 0");
|
|
139
286
|
}
|
|
140
|
-
function
|
|
287
|
+
function Ye(d) {
|
|
141
288
|
if (!Number.isFinite(d.dprCap) || d.dprCap <= 0) throw new Error("viewport.dprCap must be greater than 0");
|
|
142
289
|
}
|
|
143
|
-
function
|
|
290
|
+
function $e(d) {
|
|
144
291
|
if (!Number.isFinite(d.radius) || d.radius <= 0) throw new Error("layout.mainPegs.radius must be greater than 0");
|
|
145
292
|
if (!Number.isFinite(d.topPegCount) || d.topPegCount < 1) throw new Error("layout.mainPegs.topPegCount must be >= 1");
|
|
146
293
|
if (!Number.isFinite(d.bottomPegCount) || d.bottomPegCount < d.topPegCount) throw new Error("layout.mainPegs.bottomPegCount must be >= topPegCount");
|
|
147
294
|
if (!Number.isFinite(d.verticalStepRatio) || d.verticalStepRatio <= 0) throw new Error("layout.mainPegs.verticalStepRatio must be > 0");
|
|
148
295
|
if (!Number.isFinite(d.sidePaddingPx) || d.sidePaddingPx < 0) throw new Error("layout.mainPegs.sidePaddingPx must be >= 0");
|
|
149
296
|
}
|
|
150
|
-
var
|
|
151
|
-
(function(
|
|
152
|
-
typeof d == "object" && typeof E == "object" ? E.exports =
|
|
297
|
+
var Qe = /* @__PURE__ */ Be(((d, E) => {
|
|
298
|
+
(function(A, f) {
|
|
299
|
+
typeof d == "object" && typeof E == "object" ? E.exports = f() : typeof define == "function" && define.amd ? define("Matter", [], f) : typeof d == "object" ? d.Matter = f() : A.Matter = f();
|
|
153
300
|
})(d, function() {
|
|
154
|
-
return (function(
|
|
155
|
-
var
|
|
156
|
-
function
|
|
157
|
-
if (
|
|
158
|
-
var
|
|
301
|
+
return (function(T) {
|
|
302
|
+
var A = {};
|
|
303
|
+
function f(e) {
|
|
304
|
+
if (A[e]) return A[e].exports;
|
|
305
|
+
var o = A[e] = {
|
|
159
306
|
i: e,
|
|
160
307
|
l: !1,
|
|
161
308
|
exports: {}
|
|
162
309
|
};
|
|
163
|
-
return
|
|
310
|
+
return T[e].call(o.exports, o, o.exports, f), o.l = !0, o.exports;
|
|
164
311
|
}
|
|
165
|
-
return
|
|
166
|
-
|
|
312
|
+
return f.m = T, f.c = A, f.d = function(e, o, a) {
|
|
313
|
+
f.o(e, o) || Object.defineProperty(e, o, {
|
|
167
314
|
enumerable: !0,
|
|
168
315
|
get: a
|
|
169
316
|
});
|
|
170
|
-
},
|
|
317
|
+
}, f.r = function(e) {
|
|
171
318
|
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
|
|
172
|
-
},
|
|
173
|
-
if (
|
|
319
|
+
}, f.t = function(e, o) {
|
|
320
|
+
if (o & 1 && (e = f(e)), o & 8 || o & 4 && typeof e == "object" && e && e.__esModule) return e;
|
|
174
321
|
var a = /* @__PURE__ */ Object.create(null);
|
|
175
|
-
if (
|
|
322
|
+
if (f.r(a), Object.defineProperty(a, "default", {
|
|
176
323
|
enumerable: !0,
|
|
177
324
|
value: e
|
|
178
|
-
}),
|
|
179
|
-
return e[
|
|
325
|
+
}), o & 2 && typeof e != "string") for (var r in e) f.d(a, r, function(c) {
|
|
326
|
+
return e[c];
|
|
180
327
|
}.bind(null, r));
|
|
181
328
|
return a;
|
|
182
|
-
},
|
|
183
|
-
var
|
|
329
|
+
}, f.n = function(e) {
|
|
330
|
+
var o = e && e.__esModule ? function() {
|
|
184
331
|
return e.default;
|
|
185
332
|
} : function() {
|
|
186
333
|
return e;
|
|
187
334
|
};
|
|
188
|
-
return
|
|
189
|
-
},
|
|
190
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
191
|
-
},
|
|
335
|
+
return f.d(o, "a", o), o;
|
|
336
|
+
}, f.o = function(e, o) {
|
|
337
|
+
return Object.prototype.hasOwnProperty.call(e, o);
|
|
338
|
+
}, f.p = "", f(f.s = 20);
|
|
192
339
|
})([
|
|
193
|
-
(function(
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var r,
|
|
198
|
-
typeof a == "boolean" ? (r = 2,
|
|
340
|
+
(function(T, A) {
|
|
341
|
+
var f = {};
|
|
342
|
+
T.exports = f, (function() {
|
|
343
|
+
f._baseDelta = 1e3 / 60, f._nextId = 0, f._seed = 0, f._nowStartTime = +/* @__PURE__ */ new Date(), f._warnedOnce = {}, f._decomp = null, f.extend = function(o, a) {
|
|
344
|
+
var r, c;
|
|
345
|
+
typeof a == "boolean" ? (r = 2, c = a) : (r = 1, c = !0);
|
|
199
346
|
for (var n = r; n < arguments.length; n++) {
|
|
200
|
-
var
|
|
201
|
-
if (
|
|
202
|
-
}
|
|
203
|
-
return
|
|
204
|
-
},
|
|
205
|
-
return
|
|
206
|
-
},
|
|
207
|
-
if (Object.keys) return Object.keys(
|
|
347
|
+
var h = arguments[n];
|
|
348
|
+
if (h) for (var l in h) c && h[l] && h[l].constructor === Object && (!o[l] || o[l].constructor === Object) ? (o[l] = o[l] || {}, f.extend(o[l], c, h[l])) : o[l] = h[l];
|
|
349
|
+
}
|
|
350
|
+
return o;
|
|
351
|
+
}, f.clone = function(o, a) {
|
|
352
|
+
return f.extend({}, a, o);
|
|
353
|
+
}, f.keys = function(o) {
|
|
354
|
+
if (Object.keys) return Object.keys(o);
|
|
208
355
|
var a = [];
|
|
209
|
-
for (var r in
|
|
356
|
+
for (var r in o) a.push(r);
|
|
210
357
|
return a;
|
|
211
|
-
},
|
|
358
|
+
}, f.values = function(o) {
|
|
212
359
|
var a = [];
|
|
213
360
|
if (Object.keys) {
|
|
214
|
-
for (var r = Object.keys(
|
|
361
|
+
for (var r = Object.keys(o), c = 0; c < r.length; c++) a.push(o[r[c]]);
|
|
215
362
|
return a;
|
|
216
363
|
}
|
|
217
|
-
for (var n in
|
|
364
|
+
for (var n in o) a.push(o[n]);
|
|
218
365
|
return a;
|
|
219
|
-
},
|
|
220
|
-
a = a.split(".").slice(r,
|
|
221
|
-
for (var n = 0; n < a.length; n += 1)
|
|
222
|
-
return
|
|
223
|
-
},
|
|
224
|
-
var
|
|
225
|
-
return
|
|
226
|
-
},
|
|
227
|
-
for (var a =
|
|
228
|
-
var r = Math.floor(
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
return
|
|
232
|
-
},
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
return typeof HTMLElement < "u" ?
|
|
236
|
-
},
|
|
237
|
-
return Object.prototype.toString.call(
|
|
238
|
-
},
|
|
239
|
-
return typeof
|
|
240
|
-
},
|
|
241
|
-
return typeof
|
|
242
|
-
},
|
|
243
|
-
return toString.call(
|
|
244
|
-
},
|
|
245
|
-
return
|
|
246
|
-
},
|
|
247
|
-
return
|
|
248
|
-
},
|
|
366
|
+
}, f.get = function(o, a, r, c) {
|
|
367
|
+
a = a.split(".").slice(r, c);
|
|
368
|
+
for (var n = 0; n < a.length; n += 1) o = o[a[n]];
|
|
369
|
+
return o;
|
|
370
|
+
}, f.set = function(o, a, r, c, n) {
|
|
371
|
+
var h = a.split(".").slice(c, n);
|
|
372
|
+
return f.get(o, a, 0, -1)[h[h.length - 1]] = r, r;
|
|
373
|
+
}, f.shuffle = function(o) {
|
|
374
|
+
for (var a = o.length - 1; a > 0; a--) {
|
|
375
|
+
var r = Math.floor(f.random() * (a + 1)), c = o[a];
|
|
376
|
+
o[a] = o[r], o[r] = c;
|
|
377
|
+
}
|
|
378
|
+
return o;
|
|
379
|
+
}, f.choose = function(o) {
|
|
380
|
+
return o[Math.floor(f.random() * o.length)];
|
|
381
|
+
}, f.isElement = function(o) {
|
|
382
|
+
return typeof HTMLElement < "u" ? o instanceof HTMLElement : !!(o && o.nodeType && o.nodeName);
|
|
383
|
+
}, f.isArray = function(o) {
|
|
384
|
+
return Object.prototype.toString.call(o) === "[object Array]";
|
|
385
|
+
}, f.isFunction = function(o) {
|
|
386
|
+
return typeof o == "function";
|
|
387
|
+
}, f.isPlainObject = function(o) {
|
|
388
|
+
return typeof o == "object" && o.constructor === Object;
|
|
389
|
+
}, f.isString = function(o) {
|
|
390
|
+
return toString.call(o) === "[object String]";
|
|
391
|
+
}, f.clamp = function(o, a, r) {
|
|
392
|
+
return o < a ? a : o > r ? r : o;
|
|
393
|
+
}, f.sign = function(o) {
|
|
394
|
+
return o < 0 ? -1 : 1;
|
|
395
|
+
}, f.now = function() {
|
|
249
396
|
if (typeof window < "u" && window.performance) {
|
|
250
397
|
if (window.performance.now) return window.performance.now();
|
|
251
398
|
if (window.performance.webkitNow) return window.performance.webkitNow();
|
|
252
399
|
}
|
|
253
|
-
return Date.now ? Date.now() : /* @__PURE__ */ new Date() -
|
|
254
|
-
},
|
|
255
|
-
return
|
|
400
|
+
return Date.now ? Date.now() : /* @__PURE__ */ new Date() - f._nowStartTime;
|
|
401
|
+
}, f.random = function(o, a) {
|
|
402
|
+
return o = typeof o < "u" ? o : 0, a = typeof a < "u" ? a : 1, o + e() * (a - o);
|
|
256
403
|
};
|
|
257
404
|
var e = function() {
|
|
258
|
-
return
|
|
405
|
+
return f._seed = (f._seed * 9301 + 49297) % 233280, f._seed / 233280;
|
|
259
406
|
};
|
|
260
|
-
|
|
261
|
-
return
|
|
262
|
-
},
|
|
263
|
-
console &&
|
|
264
|
-
},
|
|
265
|
-
console &&
|
|
266
|
-
},
|
|
267
|
-
console &&
|
|
268
|
-
},
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
return
|
|
277
|
-
},
|
|
278
|
-
if (
|
|
279
|
-
for (var r = 0; r <
|
|
407
|
+
f.colorToNumber = function(o) {
|
|
408
|
+
return o = o.replace("#", ""), o.length == 3 && (o = o.charAt(0) + o.charAt(0) + o.charAt(1) + o.charAt(1) + o.charAt(2) + o.charAt(2)), parseInt(o, 16);
|
|
409
|
+
}, f.logLevel = 1, f.log = function() {
|
|
410
|
+
console && f.logLevel > 0 && f.logLevel <= 3 && console.log.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
|
|
411
|
+
}, f.info = function() {
|
|
412
|
+
console && f.logLevel > 0 && f.logLevel <= 2 && console.info.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
|
|
413
|
+
}, f.warn = function() {
|
|
414
|
+
console && f.logLevel > 0 && f.logLevel <= 3 && console.warn.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
|
|
415
|
+
}, f.warnOnce = function() {
|
|
416
|
+
var o = Array.prototype.slice.call(arguments).join(" ");
|
|
417
|
+
f._warnedOnce[o] || (f.warn(o), f._warnedOnce[o] = !0);
|
|
418
|
+
}, f.deprecated = function(o, a, r) {
|
|
419
|
+
o[a] = f.chain(function() {
|
|
420
|
+
f.warnOnce("🔅 deprecated 🔅", r);
|
|
421
|
+
}, o[a]);
|
|
422
|
+
}, f.nextId = function() {
|
|
423
|
+
return f._nextId++;
|
|
424
|
+
}, f.indexOf = function(o, a) {
|
|
425
|
+
if (o.indexOf) return o.indexOf(a);
|
|
426
|
+
for (var r = 0; r < o.length; r++) if (o[r] === a) return r;
|
|
280
427
|
return -1;
|
|
281
|
-
},
|
|
282
|
-
if (
|
|
283
|
-
for (var r = [],
|
|
428
|
+
}, f.map = function(o, a) {
|
|
429
|
+
if (o.map) return o.map(a);
|
|
430
|
+
for (var r = [], c = 0; c < o.length; c += 1) r.push(a(o[c]));
|
|
284
431
|
return r;
|
|
285
|
-
},
|
|
286
|
-
var a = [], r = [],
|
|
287
|
-
for (var n in
|
|
432
|
+
}, f.topologicalSort = function(o) {
|
|
433
|
+
var a = [], r = [], c = [];
|
|
434
|
+
for (var n in o) !r[n] && !c[n] && f._topologicalSort(n, r, c, o, a);
|
|
288
435
|
return a;
|
|
289
|
-
},
|
|
290
|
-
var
|
|
291
|
-
r[
|
|
292
|
-
for (var
|
|
293
|
-
var t =
|
|
294
|
-
r[t] || a[t] ||
|
|
295
|
-
}
|
|
296
|
-
r[
|
|
297
|
-
},
|
|
298
|
-
for (var
|
|
436
|
+
}, f._topologicalSort = function(o, a, r, c, n) {
|
|
437
|
+
var h = c[o] || [];
|
|
438
|
+
r[o] = !0;
|
|
439
|
+
for (var l = 0; l < h.length; l += 1) {
|
|
440
|
+
var t = h[l];
|
|
441
|
+
r[t] || a[t] || f._topologicalSort(t, a, r, c, n);
|
|
442
|
+
}
|
|
443
|
+
r[o] = !1, a[o] = !0, n.push(o);
|
|
444
|
+
}, f.chain = function() {
|
|
445
|
+
for (var o = [], a = 0; a < arguments.length; a += 1) {
|
|
299
446
|
var r = arguments[a];
|
|
300
|
-
r._chained ?
|
|
447
|
+
r._chained ? o.push.apply(o, r._chained) : o.push(r);
|
|
301
448
|
}
|
|
302
|
-
var
|
|
303
|
-
for (var n,
|
|
304
|
-
for (
|
|
305
|
-
var i = l
|
|
449
|
+
var c = function() {
|
|
450
|
+
for (var n, h = new Array(arguments.length), l = 0, t = arguments.length; l < t; l++) h[l] = arguments[l];
|
|
451
|
+
for (l = 0; l < o.length; l += 1) {
|
|
452
|
+
var i = o[l].apply(n, h);
|
|
306
453
|
typeof i < "u" && (n = i);
|
|
307
454
|
}
|
|
308
455
|
return n;
|
|
309
456
|
};
|
|
310
|
-
return
|
|
311
|
-
},
|
|
312
|
-
return
|
|
313
|
-
},
|
|
314
|
-
return
|
|
315
|
-
},
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
var
|
|
457
|
+
return c._chained = o, c;
|
|
458
|
+
}, f.chainPathBefore = function(o, a, r) {
|
|
459
|
+
return f.set(o, a, f.chain(r, f.get(o, a)));
|
|
460
|
+
}, f.chainPathAfter = function(o, a, r) {
|
|
461
|
+
return f.set(o, a, f.chain(f.get(o, a), r));
|
|
462
|
+
}, f.setDecomp = function(o) {
|
|
463
|
+
f._decomp = o;
|
|
464
|
+
}, f.getDecomp = function() {
|
|
465
|
+
var o = f._decomp;
|
|
319
466
|
try {
|
|
320
|
-
!
|
|
467
|
+
!o && typeof window < "u" && (o = window.decomp), !o && typeof global < "u" && (o = global.decomp);
|
|
321
468
|
} catch {
|
|
322
|
-
|
|
469
|
+
o = null;
|
|
323
470
|
}
|
|
324
|
-
return
|
|
471
|
+
return o;
|
|
325
472
|
};
|
|
326
473
|
})();
|
|
327
474
|
}),
|
|
328
|
-
(function(
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var
|
|
475
|
+
(function(T, A) {
|
|
476
|
+
var f = {};
|
|
477
|
+
T.exports = f, (function() {
|
|
478
|
+
f.create = function(e) {
|
|
479
|
+
var o = {
|
|
333
480
|
min: {
|
|
334
481
|
x: 0,
|
|
335
482
|
y: 0
|
|
@@ -339,237 +486,237 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
339
486
|
y: 0
|
|
340
487
|
}
|
|
341
488
|
};
|
|
342
|
-
return e &&
|
|
343
|
-
},
|
|
489
|
+
return e && f.update(o, e), o;
|
|
490
|
+
}, f.update = function(e, o, a) {
|
|
344
491
|
e.min.x = 1 / 0, e.max.x = -1 / 0, e.min.y = 1 / 0, e.max.y = -1 / 0;
|
|
345
|
-
for (var r = 0; r <
|
|
346
|
-
var
|
|
347
|
-
|
|
492
|
+
for (var r = 0; r < o.length; r++) {
|
|
493
|
+
var c = o[r];
|
|
494
|
+
c.x > e.max.x && (e.max.x = c.x), c.x < e.min.x && (e.min.x = c.x), c.y > e.max.y && (e.max.y = c.y), c.y < e.min.y && (e.min.y = c.y);
|
|
348
495
|
}
|
|
349
496
|
a && (a.x > 0 ? e.max.x += a.x : e.min.x += a.x, a.y > 0 ? e.max.y += a.y : e.min.y += a.y);
|
|
350
|
-
},
|
|
351
|
-
return
|
|
352
|
-
},
|
|
353
|
-
return e.min.x <=
|
|
354
|
-
},
|
|
355
|
-
e.min.x +=
|
|
356
|
-
},
|
|
497
|
+
}, f.contains = function(e, o) {
|
|
498
|
+
return o.x >= e.min.x && o.x <= e.max.x && o.y >= e.min.y && o.y <= e.max.y;
|
|
499
|
+
}, f.overlaps = function(e, o) {
|
|
500
|
+
return e.min.x <= o.max.x && e.max.x >= o.min.x && e.max.y >= o.min.y && e.min.y <= o.max.y;
|
|
501
|
+
}, f.translate = function(e, o) {
|
|
502
|
+
e.min.x += o.x, e.max.x += o.x, e.min.y += o.y, e.max.y += o.y;
|
|
503
|
+
}, f.shift = function(e, o) {
|
|
357
504
|
var a = e.max.x - e.min.x, r = e.max.y - e.min.y;
|
|
358
|
-
e.min.x =
|
|
505
|
+
e.min.x = o.x, e.max.x = o.x + a, e.min.y = o.y, e.max.y = o.y + r;
|
|
359
506
|
};
|
|
360
507
|
})();
|
|
361
508
|
}),
|
|
362
|
-
(function(
|
|
363
|
-
var
|
|
364
|
-
|
|
365
|
-
|
|
509
|
+
(function(T, A) {
|
|
510
|
+
var f = {};
|
|
511
|
+
T.exports = f, (function() {
|
|
512
|
+
f.create = function(e, o) {
|
|
366
513
|
return {
|
|
367
514
|
x: e || 0,
|
|
368
|
-
y:
|
|
515
|
+
y: o || 0
|
|
369
516
|
};
|
|
370
|
-
},
|
|
517
|
+
}, f.clone = function(e) {
|
|
371
518
|
return {
|
|
372
519
|
x: e.x,
|
|
373
520
|
y: e.y
|
|
374
521
|
};
|
|
375
|
-
},
|
|
522
|
+
}, f.magnitude = function(e) {
|
|
376
523
|
return Math.sqrt(e.x * e.x + e.y * e.y);
|
|
377
|
-
},
|
|
524
|
+
}, f.magnitudeSquared = function(e) {
|
|
378
525
|
return e.x * e.x + e.y * e.y;
|
|
379
|
-
},
|
|
380
|
-
var r = Math.cos(
|
|
526
|
+
}, f.rotate = function(e, o, a) {
|
|
527
|
+
var r = Math.cos(o), c = Math.sin(o);
|
|
381
528
|
a || (a = {});
|
|
382
|
-
var n = e.x * r - e.y *
|
|
383
|
-
return a.y = e.x *
|
|
384
|
-
},
|
|
385
|
-
var
|
|
529
|
+
var n = e.x * r - e.y * c;
|
|
530
|
+
return a.y = e.x * c + e.y * r, a.x = n, a;
|
|
531
|
+
}, f.rotateAbout = function(e, o, a, r) {
|
|
532
|
+
var c = Math.cos(o), n = Math.sin(o);
|
|
386
533
|
r || (r = {});
|
|
387
|
-
var
|
|
388
|
-
return r.y = a.y + ((e.x - a.x) * n + (e.y - a.y) *
|
|
389
|
-
},
|
|
390
|
-
var
|
|
391
|
-
return
|
|
534
|
+
var h = a.x + ((e.x - a.x) * c - (e.y - a.y) * n);
|
|
535
|
+
return r.y = a.y + ((e.x - a.x) * n + (e.y - a.y) * c), r.x = h, r;
|
|
536
|
+
}, f.normalise = function(e) {
|
|
537
|
+
var o = f.magnitude(e);
|
|
538
|
+
return o === 0 ? {
|
|
392
539
|
x: 0,
|
|
393
540
|
y: 0
|
|
394
541
|
} : {
|
|
395
|
-
x: e.x /
|
|
396
|
-
y: e.y /
|
|
542
|
+
x: e.x / o,
|
|
543
|
+
y: e.y / o
|
|
397
544
|
};
|
|
398
|
-
},
|
|
399
|
-
return e.x *
|
|
400
|
-
},
|
|
401
|
-
return e.x *
|
|
402
|
-
},
|
|
403
|
-
return (
|
|
404
|
-
},
|
|
405
|
-
return a || (a = {}), a.x = e.x +
|
|
406
|
-
},
|
|
407
|
-
return a || (a = {}), a.x = e.x -
|
|
408
|
-
},
|
|
545
|
+
}, f.dot = function(e, o) {
|
|
546
|
+
return e.x * o.x + e.y * o.y;
|
|
547
|
+
}, f.cross = function(e, o) {
|
|
548
|
+
return e.x * o.y - e.y * o.x;
|
|
549
|
+
}, f.cross3 = function(e, o, a) {
|
|
550
|
+
return (o.x - e.x) * (a.y - e.y) - (o.y - e.y) * (a.x - e.x);
|
|
551
|
+
}, f.add = function(e, o, a) {
|
|
552
|
+
return a || (a = {}), a.x = e.x + o.x, a.y = e.y + o.y, a;
|
|
553
|
+
}, f.sub = function(e, o, a) {
|
|
554
|
+
return a || (a = {}), a.x = e.x - o.x, a.y = e.y - o.y, a;
|
|
555
|
+
}, f.mult = function(e, o) {
|
|
409
556
|
return {
|
|
410
|
-
x: e.x *
|
|
411
|
-
y: e.y *
|
|
557
|
+
x: e.x * o,
|
|
558
|
+
y: e.y * o
|
|
412
559
|
};
|
|
413
|
-
},
|
|
560
|
+
}, f.div = function(e, o) {
|
|
414
561
|
return {
|
|
415
|
-
x: e.x /
|
|
416
|
-
y: e.y /
|
|
562
|
+
x: e.x / o,
|
|
563
|
+
y: e.y / o
|
|
417
564
|
};
|
|
418
|
-
},
|
|
419
|
-
return
|
|
420
|
-
x:
|
|
421
|
-
y:
|
|
565
|
+
}, f.perp = function(e, o) {
|
|
566
|
+
return o = o === !0 ? -1 : 1, {
|
|
567
|
+
x: o * -e.y,
|
|
568
|
+
y: o * e.x
|
|
422
569
|
};
|
|
423
|
-
},
|
|
570
|
+
}, f.neg = function(e) {
|
|
424
571
|
return {
|
|
425
572
|
x: -e.x,
|
|
426
573
|
y: -e.y
|
|
427
574
|
};
|
|
428
|
-
},
|
|
429
|
-
return Math.atan2(
|
|
430
|
-
},
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
575
|
+
}, f.angle = function(e, o) {
|
|
576
|
+
return Math.atan2(o.y - e.y, o.x - e.x);
|
|
577
|
+
}, f._temp = [
|
|
578
|
+
f.create(),
|
|
579
|
+
f.create(),
|
|
580
|
+
f.create(),
|
|
581
|
+
f.create(),
|
|
582
|
+
f.create(),
|
|
583
|
+
f.create()
|
|
437
584
|
];
|
|
438
585
|
})();
|
|
439
586
|
}),
|
|
440
|
-
(function(
|
|
587
|
+
(function(T, A, f) {
|
|
441
588
|
var e = {};
|
|
442
|
-
|
|
443
|
-
var
|
|
589
|
+
T.exports = e;
|
|
590
|
+
var o = f(2), a = f(0);
|
|
444
591
|
(function() {
|
|
445
|
-
e.create = function(r,
|
|
446
|
-
for (var n = [],
|
|
447
|
-
var
|
|
448
|
-
x:
|
|
449
|
-
y:
|
|
450
|
-
index:
|
|
451
|
-
body:
|
|
592
|
+
e.create = function(r, c) {
|
|
593
|
+
for (var n = [], h = 0; h < r.length; h++) {
|
|
594
|
+
var l = r[h], t = {
|
|
595
|
+
x: l.x,
|
|
596
|
+
y: l.y,
|
|
597
|
+
index: h,
|
|
598
|
+
body: c,
|
|
452
599
|
isInternal: !1
|
|
453
600
|
};
|
|
454
601
|
n.push(t);
|
|
455
602
|
}
|
|
456
603
|
return n;
|
|
457
|
-
}, e.fromPath = function(r,
|
|
458
|
-
var n = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi,
|
|
459
|
-
return r.replace(n, function(
|
|
460
|
-
|
|
604
|
+
}, e.fromPath = function(r, c) {
|
|
605
|
+
var n = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi, h = [];
|
|
606
|
+
return r.replace(n, function(l, t, i) {
|
|
607
|
+
h.push({
|
|
461
608
|
x: parseFloat(t),
|
|
462
609
|
y: parseFloat(i)
|
|
463
610
|
});
|
|
464
|
-
}), e.create(
|
|
611
|
+
}), e.create(h, c);
|
|
465
612
|
}, e.centre = function(r) {
|
|
466
|
-
for (var
|
|
613
|
+
for (var c = e.area(r, !0), n = {
|
|
467
614
|
x: 0,
|
|
468
615
|
y: 0
|
|
469
|
-
},
|
|
470
|
-
t = (i + 1) % r.length,
|
|
471
|
-
return
|
|
616
|
+
}, h, l, t, i = 0; i < r.length; i++)
|
|
617
|
+
t = (i + 1) % r.length, h = o.cross(r[i], r[t]), l = o.mult(o.add(r[i], r[t]), h), n = o.add(n, l);
|
|
618
|
+
return o.div(n, 6 * c);
|
|
472
619
|
}, e.mean = function(r) {
|
|
473
|
-
for (var
|
|
620
|
+
for (var c = {
|
|
474
621
|
x: 0,
|
|
475
622
|
y: 0
|
|
476
623
|
}, n = 0; n < r.length; n++)
|
|
477
|
-
|
|
478
|
-
return
|
|
479
|
-
}, e.area = function(r,
|
|
480
|
-
for (var n = 0,
|
|
481
|
-
n += (r[
|
|
482
|
-
return
|
|
483
|
-
}, e.inertia = function(r,
|
|
484
|
-
for (var n = 0,
|
|
485
|
-
i = (s + 1) %
|
|
486
|
-
return
|
|
487
|
-
}, e.translate = function(r,
|
|
624
|
+
c.x += r[n].x, c.y += r[n].y;
|
|
625
|
+
return o.div(c, r.length);
|
|
626
|
+
}, e.area = function(r, c) {
|
|
627
|
+
for (var n = 0, h = r.length - 1, l = 0; l < r.length; l++)
|
|
628
|
+
n += (r[h].x - r[l].x) * (r[h].y + r[l].y), h = l;
|
|
629
|
+
return c ? n / 2 : Math.abs(n) / 2;
|
|
630
|
+
}, e.inertia = function(r, c) {
|
|
631
|
+
for (var n = 0, h = 0, l = r, t, i, s = 0; s < l.length; s++)
|
|
632
|
+
i = (s + 1) % l.length, t = Math.abs(o.cross(l[i], l[s])), n += t * (o.dot(l[i], l[i]) + o.dot(l[i], l[s]) + o.dot(l[s], l[s])), h += t;
|
|
633
|
+
return c / 6 * (n / h);
|
|
634
|
+
}, e.translate = function(r, c, n) {
|
|
488
635
|
n = typeof n < "u" ? n : 1;
|
|
489
|
-
var
|
|
490
|
-
for (i = 0; i <
|
|
491
|
-
r[i].x +=
|
|
636
|
+
var h = r.length, l = c.x * n, t = c.y * n, i;
|
|
637
|
+
for (i = 0; i < h; i++)
|
|
638
|
+
r[i].x += l, r[i].y += t;
|
|
492
639
|
return r;
|
|
493
|
-
}, e.rotate = function(r,
|
|
494
|
-
if (
|
|
495
|
-
var
|
|
640
|
+
}, e.rotate = function(r, c, n) {
|
|
641
|
+
if (c !== 0) {
|
|
642
|
+
var h = Math.cos(c), l = Math.sin(c), t = n.x, i = n.y, s = r.length, u, m, x, P;
|
|
496
643
|
for (P = 0; P < s; P++)
|
|
497
|
-
|
|
644
|
+
u = r[P], m = u.x - t, x = u.y - i, u.x = t + (m * h - x * l), u.y = i + (m * l + x * h);
|
|
498
645
|
return r;
|
|
499
646
|
}
|
|
500
|
-
}, e.contains = function(r,
|
|
501
|
-
for (var n =
|
|
502
|
-
if (i = r[s], (n - t.x) * (i.y - t.y) + (
|
|
647
|
+
}, e.contains = function(r, c) {
|
|
648
|
+
for (var n = c.x, h = c.y, l = r.length, t = r[l - 1], i, s = 0; s < l; s++) {
|
|
649
|
+
if (i = r[s], (n - t.x) * (i.y - t.y) + (h - t.y) * (t.x - i.x) > 0) return !1;
|
|
503
650
|
t = i;
|
|
504
651
|
}
|
|
505
652
|
return !0;
|
|
506
|
-
}, e.scale = function(r,
|
|
507
|
-
if (
|
|
508
|
-
|
|
509
|
-
for (var
|
|
510
|
-
|
|
653
|
+
}, e.scale = function(r, c, n, h) {
|
|
654
|
+
if (c === 1 && n === 1) return r;
|
|
655
|
+
h = h || e.centre(r);
|
|
656
|
+
for (var l, t, i = 0; i < r.length; i++)
|
|
657
|
+
l = r[i], t = o.sub(l, h), r[i].x = h.x + t.x * c, r[i].y = h.y + t.y * n;
|
|
511
658
|
return r;
|
|
512
|
-
}, e.chamfer = function(r,
|
|
513
|
-
typeof
|
|
659
|
+
}, e.chamfer = function(r, c, n, h, l) {
|
|
660
|
+
typeof c == "number" ? c = [c] : c = c || [8], n = typeof n < "u" ? n : -1, h = h || 2, l = l || 14;
|
|
514
661
|
for (var t = [], i = 0; i < r.length; i++) {
|
|
515
|
-
var s = r[i - 1 >= 0 ? i - 1 : r.length - 1],
|
|
662
|
+
var s = r[i - 1 >= 0 ? i - 1 : r.length - 1], u = r[i], m = r[(i + 1) % r.length], x = c[i < c.length ? i : c.length - 1];
|
|
516
663
|
if (x === 0) {
|
|
517
|
-
t.push(
|
|
664
|
+
t.push(u);
|
|
518
665
|
continue;
|
|
519
666
|
}
|
|
520
|
-
var P =
|
|
521
|
-
x:
|
|
522
|
-
y: s.x -
|
|
523
|
-
}),
|
|
524
|
-
x: m.y -
|
|
525
|
-
y:
|
|
526
|
-
}), g = Math.sqrt(2 * Math.pow(x, 2)), p =
|
|
527
|
-
n === -1 && (w = Math.pow(x, 0.32) * 1.75), w = a.clamp(w,
|
|
528
|
-
for (var S = Math.acos(
|
|
667
|
+
var P = o.normalise({
|
|
668
|
+
x: u.y - s.y,
|
|
669
|
+
y: s.x - u.x
|
|
670
|
+
}), B = o.normalise({
|
|
671
|
+
x: m.y - u.y,
|
|
672
|
+
y: u.x - m.x
|
|
673
|
+
}), g = Math.sqrt(2 * Math.pow(x, 2)), p = o.mult(a.clone(P), x), y = o.normalise(o.mult(o.add(P, B), 0.5)), v = o.sub(u, o.mult(y, g)), w = n;
|
|
674
|
+
n === -1 && (w = Math.pow(x, 0.32) * 1.75), w = a.clamp(w, h, l), w % 2 === 1 && (w += 1);
|
|
675
|
+
for (var S = Math.acos(o.dot(P, B)) / w, C = 0; C < w; C++) t.push(o.add(o.rotate(p, S * C), v));
|
|
529
676
|
}
|
|
530
677
|
return t;
|
|
531
678
|
}, e.clockwiseSort = function(r) {
|
|
532
|
-
var
|
|
533
|
-
return r.sort(function(n,
|
|
534
|
-
return
|
|
679
|
+
var c = e.mean(r);
|
|
680
|
+
return r.sort(function(n, h) {
|
|
681
|
+
return o.angle(c, n) - o.angle(c, h);
|
|
535
682
|
}), r;
|
|
536
683
|
}, e.isConvex = function(r) {
|
|
537
|
-
var
|
|
684
|
+
var c = 0, n = r.length, h, l, t, i;
|
|
538
685
|
if (n < 3) return null;
|
|
539
|
-
for (
|
|
540
|
-
if (
|
|
541
|
-
return
|
|
686
|
+
for (h = 0; h < n; h++)
|
|
687
|
+
if (l = (h + 1) % n, t = (h + 2) % n, i = (r[l].x - r[h].x) * (r[t].y - r[l].y), i -= (r[l].y - r[h].y) * (r[t].x - r[l].x), i < 0 ? c |= 1 : i > 0 && (c |= 2), c === 3) return !1;
|
|
688
|
+
return c !== 0 ? !0 : null;
|
|
542
689
|
}, e.hull = function(r) {
|
|
543
|
-
var
|
|
690
|
+
var c = [], n = [], h, l;
|
|
544
691
|
for (r = r.slice(0), r.sort(function(t, i) {
|
|
545
692
|
var s = t.x - i.x;
|
|
546
693
|
return s !== 0 ? s : t.y - i.y;
|
|
547
|
-
}),
|
|
548
|
-
for (
|
|
549
|
-
n.push(
|
|
694
|
+
}), l = 0; l < r.length; l += 1) {
|
|
695
|
+
for (h = r[l]; n.length >= 2 && o.cross3(n[n.length - 2], n[n.length - 1], h) <= 0; ) n.pop();
|
|
696
|
+
n.push(h);
|
|
550
697
|
}
|
|
551
|
-
for (
|
|
552
|
-
for (
|
|
553
|
-
|
|
698
|
+
for (l = r.length - 1; l >= 0; l -= 1) {
|
|
699
|
+
for (h = r[l]; c.length >= 2 && o.cross3(c[c.length - 2], c[c.length - 1], h) <= 0; ) c.pop();
|
|
700
|
+
c.push(h);
|
|
554
701
|
}
|
|
555
|
-
return
|
|
702
|
+
return c.pop(), n.pop(), c.concat(n);
|
|
556
703
|
};
|
|
557
704
|
})();
|
|
558
705
|
}),
|
|
559
|
-
(function(
|
|
706
|
+
(function(T, A, f) {
|
|
560
707
|
var e = {};
|
|
561
|
-
|
|
562
|
-
var
|
|
708
|
+
T.exports = e;
|
|
709
|
+
var o = f(3), a = f(2), r = f(7), c = f(0), n = f(1), h = f(11);
|
|
563
710
|
(function() {
|
|
564
711
|
e._timeCorrection = !0, e._inertiaScale = 4, e._nextCollidingGroupId = 1, e._nextNonCollidingGroupId = -1, e._nextCategory = 1, e._baseDelta = 1e3 / 60, e.create = function(t) {
|
|
565
712
|
var i = {
|
|
566
|
-
id:
|
|
713
|
+
id: c.nextId(),
|
|
567
714
|
type: "body",
|
|
568
715
|
label: "Body",
|
|
569
716
|
parts: [],
|
|
570
717
|
plugin: {},
|
|
571
718
|
angle: 0,
|
|
572
|
-
vertices:
|
|
719
|
+
vertices: o.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),
|
|
573
720
|
position: {
|
|
574
721
|
x: 0,
|
|
575
722
|
y: 0
|
|
@@ -639,14 +786,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
639
786
|
inertia: 0,
|
|
640
787
|
deltaTime: 16.666666666666668,
|
|
641
788
|
_original: null
|
|
642
|
-
}, s =
|
|
643
|
-
return
|
|
789
|
+
}, s = c.extend(i, t);
|
|
790
|
+
return l(s, t), s;
|
|
644
791
|
}, e.nextGroup = function(t) {
|
|
645
792
|
return t ? e._nextNonCollidingGroupId-- : e._nextCollidingGroupId++;
|
|
646
793
|
}, e.nextCategory = function() {
|
|
647
794
|
return e._nextCategory = e._nextCategory << 1, e._nextCategory;
|
|
648
795
|
};
|
|
649
|
-
var
|
|
796
|
+
var l = function(t, i) {
|
|
650
797
|
i = i || {}, e.set(t, {
|
|
651
798
|
bounds: t.bounds || n.create(t.vertices),
|
|
652
799
|
positionPrev: t.positionPrev || a.clone(t.position),
|
|
@@ -656,27 +803,27 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
656
803
|
isStatic: t.isStatic,
|
|
657
804
|
isSleeping: t.isSleeping,
|
|
658
805
|
parent: t.parent || t
|
|
659
|
-
}),
|
|
806
|
+
}), o.rotate(t.vertices, t.angle, t.position), h.rotate(t.axes, t.angle), n.update(t.bounds, t.vertices, t.velocity), e.set(t, {
|
|
660
807
|
axes: i.axes || t.axes,
|
|
661
808
|
area: i.area || t.area,
|
|
662
809
|
mass: i.mass || t.mass,
|
|
663
810
|
inertia: i.inertia || t.inertia
|
|
664
811
|
});
|
|
665
|
-
var s = t.isStatic ? "#14151f" :
|
|
812
|
+
var s = t.isStatic ? "#14151f" : c.choose([
|
|
666
813
|
"#f19648",
|
|
667
814
|
"#f5d259",
|
|
668
815
|
"#f55a3c",
|
|
669
816
|
"#063e7b",
|
|
670
817
|
"#ececd1"
|
|
671
|
-
]),
|
|
672
|
-
t.render.fillStyle = t.render.fillStyle || s, t.render.strokeStyle = t.render.strokeStyle ||
|
|
818
|
+
]), u = t.isStatic ? "#555" : "#ccc", m = t.isStatic && t.render.fillStyle === null ? 1 : 0;
|
|
819
|
+
t.render.fillStyle = t.render.fillStyle || s, t.render.strokeStyle = t.render.strokeStyle || u, t.render.lineWidth = t.render.lineWidth || m, t.render.sprite.xOffset += -(t.bounds.min.x - t.position.x) / (t.bounds.max.x - t.bounds.min.x), t.render.sprite.yOffset += -(t.bounds.min.y - t.position.y) / (t.bounds.max.y - t.bounds.min.y);
|
|
673
820
|
};
|
|
674
821
|
e.set = function(t, i, s) {
|
|
675
|
-
var
|
|
676
|
-
typeof i == "string" && (
|
|
677
|
-
for (
|
|
678
|
-
if (Object.prototype.hasOwnProperty.call(i,
|
|
679
|
-
switch (s = i[
|
|
822
|
+
var u;
|
|
823
|
+
typeof i == "string" && (u = i, i = {}, i[u] = s);
|
|
824
|
+
for (u in i)
|
|
825
|
+
if (Object.prototype.hasOwnProperty.call(i, u))
|
|
826
|
+
switch (s = i[u], u) {
|
|
680
827
|
case "isStatic":
|
|
681
828
|
e.setStatic(t, s);
|
|
682
829
|
break;
|
|
@@ -720,20 +867,20 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
720
867
|
e.setCentre(t, s);
|
|
721
868
|
break;
|
|
722
869
|
default:
|
|
723
|
-
t[
|
|
870
|
+
t[u] = s;
|
|
724
871
|
}
|
|
725
872
|
}, e.setStatic = function(t, i) {
|
|
726
873
|
for (var s = 0; s < t.parts.length; s++) {
|
|
727
|
-
var
|
|
728
|
-
i ? (
|
|
729
|
-
restitution:
|
|
730
|
-
friction:
|
|
731
|
-
mass:
|
|
732
|
-
inertia:
|
|
733
|
-
density:
|
|
734
|
-
inverseMass:
|
|
735
|
-
inverseInertia:
|
|
736
|
-
}),
|
|
874
|
+
var u = t.parts[s];
|
|
875
|
+
i ? (u.isStatic || (u._original = {
|
|
876
|
+
restitution: u.restitution,
|
|
877
|
+
friction: u.friction,
|
|
878
|
+
mass: u.mass,
|
|
879
|
+
inertia: u.inertia,
|
|
880
|
+
density: u.density,
|
|
881
|
+
inverseMass: u.inverseMass,
|
|
882
|
+
inverseInertia: u.inverseInertia
|
|
883
|
+
}), u.restitution = 0, u.friction = 1, u.mass = u.inertia = u.density = 1 / 0, u.inverseMass = u.inverseInertia = 0, u.positionPrev.x = u.position.x, u.positionPrev.y = u.position.y, u.anglePrev = u.angle, u.angularVelocity = 0, u.speed = 0, u.angularSpeed = 0, u.motion = 0) : u._original && (u.restitution = u._original.restitution, u.friction = u._original.friction, u.mass = u._original.mass, u.inertia = u._original.inertia, u.density = u._original.density, u.inverseMass = u._original.inverseMass, u.inverseInertia = u._original.inverseInertia, u._original = null), u.isStatic = i;
|
|
737
884
|
}
|
|
738
885
|
}, e.setMass = function(t, i) {
|
|
739
886
|
t.inertia = t.inertia / (t.mass / 6) * (i / 6), t.inverseInertia = 1 / t.inertia, t.mass = i, t.inverseMass = 1 / t.mass, t.density = t.mass / t.area;
|
|
@@ -742,22 +889,22 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
742
889
|
}, e.setInertia = function(t, i) {
|
|
743
890
|
t.inertia = i, t.inverseInertia = 1 / t.inertia;
|
|
744
891
|
}, e.setVertices = function(t, i) {
|
|
745
|
-
i[0].body === t ? t.vertices = i : t.vertices =
|
|
746
|
-
var s =
|
|
747
|
-
|
|
892
|
+
i[0].body === t ? t.vertices = i : t.vertices = o.create(i, t), t.axes = h.fromVertices(t.vertices), t.area = o.area(t.vertices), e.setMass(t, t.density * t.area);
|
|
893
|
+
var s = o.centre(t.vertices);
|
|
894
|
+
o.translate(t.vertices, s, -1), e.setInertia(t, e._inertiaScale * o.inertia(t.vertices, t.mass)), o.translate(t.vertices, t.position), n.update(t.bounds, t.vertices, t.velocity);
|
|
748
895
|
}, e.setParts = function(t, i, s) {
|
|
749
|
-
var
|
|
750
|
-
for (i = i.slice(0), t.parts.length = 0, t.parts.push(t), t.parent = t,
|
|
751
|
-
var m = i[
|
|
896
|
+
var u;
|
|
897
|
+
for (i = i.slice(0), t.parts.length = 0, t.parts.push(t), t.parent = t, u = 0; u < i.length; u++) {
|
|
898
|
+
var m = i[u];
|
|
752
899
|
m !== t && (m.parent = t, t.parts.push(m));
|
|
753
900
|
}
|
|
754
901
|
if (t.parts.length !== 1) {
|
|
755
902
|
if (s = typeof s < "u" ? s : !0, s) {
|
|
756
903
|
var x = [];
|
|
757
|
-
for (
|
|
758
|
-
|
|
759
|
-
var P =
|
|
760
|
-
e.setVertices(t, P),
|
|
904
|
+
for (u = 0; u < i.length; u++) x = x.concat(i[u].vertices);
|
|
905
|
+
o.clockwiseSort(x);
|
|
906
|
+
var P = o.hull(x), B = o.centre(P);
|
|
907
|
+
e.setVertices(t, P), o.translate(t.vertices, B);
|
|
761
908
|
}
|
|
762
909
|
var g = e._totalProperties(t);
|
|
763
910
|
t.area = g.area, t.parent = t, t.position.x = g.centre.x, t.position.y = g.centre.y, t.positionPrev.x = g.centre.x, t.positionPrev.y = g.centre.y, e.setMass(t, g.mass), e.setInertia(t, g.inertia), e.setPosition(t, g.centre);
|
|
@@ -765,18 +912,18 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
765
912
|
}, e.setCentre = function(t, i, s) {
|
|
766
913
|
s ? (t.positionPrev.x += i.x, t.positionPrev.y += i.y, t.position.x += i.x, t.position.y += i.y) : (t.positionPrev.x = i.x - (t.position.x - t.positionPrev.x), t.positionPrev.y = i.y - (t.position.y - t.positionPrev.y), t.position.x = i.x, t.position.y = i.y);
|
|
767
914
|
}, e.setPosition = function(t, i, s) {
|
|
768
|
-
var
|
|
769
|
-
s ? (t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.velocity.x =
|
|
915
|
+
var u = a.sub(i, t.position);
|
|
916
|
+
s ? (t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.velocity.x = u.x, t.velocity.y = u.y, t.speed = a.magnitude(u)) : (t.positionPrev.x += u.x, t.positionPrev.y += u.y);
|
|
770
917
|
for (var m = 0; m < t.parts.length; m++) {
|
|
771
918
|
var x = t.parts[m];
|
|
772
|
-
x.position.x +=
|
|
919
|
+
x.position.x += u.x, x.position.y += u.y, o.translate(x.vertices, u), n.update(x.bounds, x.vertices, t.velocity);
|
|
773
920
|
}
|
|
774
921
|
}, e.setAngle = function(t, i, s) {
|
|
775
|
-
var
|
|
776
|
-
s ? (t.anglePrev = t.angle, t.angularVelocity =
|
|
922
|
+
var u = i - t.angle;
|
|
923
|
+
s ? (t.anglePrev = t.angle, t.angularVelocity = u, t.angularSpeed = Math.abs(u)) : t.anglePrev += u;
|
|
777
924
|
for (var m = 0; m < t.parts.length; m++) {
|
|
778
925
|
var x = t.parts[m];
|
|
779
|
-
x.angle +=
|
|
926
|
+
x.angle += u, o.rotate(x.vertices, u, t.position), h.rotate(x.axes, u), n.update(x.bounds, x.vertices, t.velocity), m > 0 && a.rotateAbout(x.position, u, t.position, x.position);
|
|
780
927
|
}
|
|
781
928
|
}, e.setVelocity = function(t, i) {
|
|
782
929
|
var s = t.deltaTime / e._baseDelta;
|
|
@@ -799,49 +946,49 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
799
946
|
}, e.getAngularSpeed = function(t) {
|
|
800
947
|
return Math.abs(e.getAngularVelocity(t));
|
|
801
948
|
}, e.setAngularSpeed = function(t, i) {
|
|
802
|
-
e.setAngularVelocity(t,
|
|
949
|
+
e.setAngularVelocity(t, c.sign(e.getAngularVelocity(t)) * i);
|
|
803
950
|
}, e.translate = function(t, i, s) {
|
|
804
951
|
e.setPosition(t, a.add(t.position, i), s);
|
|
805
|
-
}, e.rotate = function(t, i, s,
|
|
806
|
-
if (!s) e.setAngle(t, t.angle + i,
|
|
952
|
+
}, e.rotate = function(t, i, s, u) {
|
|
953
|
+
if (!s) e.setAngle(t, t.angle + i, u);
|
|
807
954
|
else {
|
|
808
|
-
var m = Math.cos(i), x = Math.sin(i), P = t.position.x - s.x,
|
|
955
|
+
var m = Math.cos(i), x = Math.sin(i), P = t.position.x - s.x, B = t.position.y - s.y;
|
|
809
956
|
e.setPosition(t, {
|
|
810
|
-
x: s.x + (P * m -
|
|
811
|
-
y: s.y + (P * x +
|
|
812
|
-
},
|
|
957
|
+
x: s.x + (P * m - B * x),
|
|
958
|
+
y: s.y + (P * x + B * m)
|
|
959
|
+
}, u), e.setAngle(t, t.angle + i, u);
|
|
813
960
|
}
|
|
814
|
-
}, e.scale = function(t, i, s,
|
|
961
|
+
}, e.scale = function(t, i, s, u) {
|
|
815
962
|
var m = 0, x = 0;
|
|
816
|
-
|
|
963
|
+
u = u || t.position;
|
|
817
964
|
for (var P = 0; P < t.parts.length; P++) {
|
|
818
|
-
var
|
|
819
|
-
|
|
820
|
-
x: -
|
|
821
|
-
y: -
|
|
822
|
-
}), e.setInertia(
|
|
823
|
-
x:
|
|
824
|
-
y:
|
|
825
|
-
}), P > 0 && (m +=
|
|
965
|
+
var B = t.parts[P];
|
|
966
|
+
o.scale(B.vertices, i, s, u), B.axes = h.fromVertices(B.vertices), B.area = o.area(B.vertices), e.setMass(B, t.density * B.area), o.translate(B.vertices, {
|
|
967
|
+
x: -B.position.x,
|
|
968
|
+
y: -B.position.y
|
|
969
|
+
}), e.setInertia(B, e._inertiaScale * o.inertia(B.vertices, B.mass)), o.translate(B.vertices, {
|
|
970
|
+
x: B.position.x,
|
|
971
|
+
y: B.position.y
|
|
972
|
+
}), P > 0 && (m += B.area, x += B.inertia), B.position.x = u.x + (B.position.x - u.x) * i, B.position.y = u.y + (B.position.y - u.y) * s, n.update(B.bounds, B.vertices, t.velocity);
|
|
826
973
|
}
|
|
827
974
|
t.parts.length > 1 && (t.area = m, t.isStatic || (e.setMass(t, t.density * m), e.setInertia(t, x))), t.circleRadius && (i === s ? t.circleRadius *= i : t.circleRadius = null);
|
|
828
975
|
}, e.update = function(t, i) {
|
|
829
976
|
i = (typeof i < "u" ? i : 1e3 / 60) * t.timeScale;
|
|
830
|
-
var s = i * i,
|
|
831
|
-
t.velocity.x = x * m + t.force.x / t.mass * s, t.velocity.y = P * m + t.force.y / t.mass * s, t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.position.x += t.velocity.x, t.position.y += t.velocity.y, t.deltaTime = i, t.angularVelocity = (t.angle - t.anglePrev) * m *
|
|
832
|
-
for (var
|
|
833
|
-
var g = t.parts[
|
|
834
|
-
|
|
977
|
+
var s = i * i, u = e._timeCorrection ? i / (t.deltaTime || i) : 1, m = 1 - t.frictionAir * (i / c._baseDelta), x = (t.position.x - t.positionPrev.x) * u, P = (t.position.y - t.positionPrev.y) * u;
|
|
978
|
+
t.velocity.x = x * m + t.force.x / t.mass * s, t.velocity.y = P * m + t.force.y / t.mass * s, t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.position.x += t.velocity.x, t.position.y += t.velocity.y, t.deltaTime = i, t.angularVelocity = (t.angle - t.anglePrev) * m * u + t.torque / t.inertia * s, t.anglePrev = t.angle, t.angle += t.angularVelocity;
|
|
979
|
+
for (var B = 0; B < t.parts.length; B++) {
|
|
980
|
+
var g = t.parts[B];
|
|
981
|
+
o.translate(g.vertices, t.velocity), B > 0 && (g.position.x += t.velocity.x, g.position.y += t.velocity.y), t.angularVelocity !== 0 && (o.rotate(g.vertices, t.angularVelocity, t.position), h.rotate(g.axes, t.angularVelocity), B > 0 && a.rotateAbout(g.position, t.angularVelocity, t.position, g.position)), n.update(g.bounds, g.vertices, t.velocity);
|
|
835
982
|
}
|
|
836
983
|
}, e.updateVelocities = function(t) {
|
|
837
984
|
var i = e._baseDelta / t.deltaTime, s = t.velocity;
|
|
838
985
|
s.x = (t.position.x - t.positionPrev.x) * i, s.y = (t.position.y - t.positionPrev.y) * i, t.speed = Math.sqrt(s.x * s.x + s.y * s.y), t.angularVelocity = (t.angle - t.anglePrev) * i, t.angularSpeed = Math.abs(t.angularVelocity);
|
|
839
986
|
}, e.applyForce = function(t, i, s) {
|
|
840
|
-
var
|
|
987
|
+
var u = {
|
|
841
988
|
x: i.x - t.position.x,
|
|
842
989
|
y: i.y - t.position.y
|
|
843
990
|
};
|
|
844
|
-
t.force.x += s.x, t.force.y += s.y, t.torque +=
|
|
991
|
+
t.force.x += s.x, t.force.y += s.y, t.torque += u.x * s.y - u.y * s.x;
|
|
845
992
|
}, e._totalProperties = function(t) {
|
|
846
993
|
for (var i = {
|
|
847
994
|
mass: 0,
|
|
@@ -852,51 +999,51 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
852
999
|
y: 0
|
|
853
1000
|
}
|
|
854
1001
|
}, s = t.parts.length === 1 ? 0 : 1; s < t.parts.length; s++) {
|
|
855
|
-
var
|
|
856
|
-
i.mass += m, i.area +=
|
|
1002
|
+
var u = t.parts[s], m = u.mass !== 1 / 0 ? u.mass : 1;
|
|
1003
|
+
i.mass += m, i.area += u.area, i.inertia += u.inertia, i.centre = a.add(i.centre, a.mult(u.position, m));
|
|
857
1004
|
}
|
|
858
1005
|
return i.centre = a.div(i.centre, i.mass), i;
|
|
859
1006
|
};
|
|
860
1007
|
})();
|
|
861
1008
|
}),
|
|
862
|
-
(function(
|
|
1009
|
+
(function(T, A, f) {
|
|
863
1010
|
var e = {};
|
|
864
|
-
|
|
865
|
-
var
|
|
1011
|
+
T.exports = e;
|
|
1012
|
+
var o = f(0);
|
|
866
1013
|
(function() {
|
|
867
|
-
e.on = function(a, r,
|
|
868
|
-
for (var n = r.split(" "),
|
|
869
|
-
|
|
870
|
-
return
|
|
871
|
-
}, e.off = function(a, r,
|
|
1014
|
+
e.on = function(a, r, c) {
|
|
1015
|
+
for (var n = r.split(" "), h, l = 0; l < n.length; l++)
|
|
1016
|
+
h = n[l], a.events = a.events || {}, a.events[h] = a.events[h] || [], a.events[h].push(c);
|
|
1017
|
+
return c;
|
|
1018
|
+
}, e.off = function(a, r, c) {
|
|
872
1019
|
if (!r) {
|
|
873
1020
|
a.events = {};
|
|
874
1021
|
return;
|
|
875
1022
|
}
|
|
876
|
-
typeof r == "function" && (
|
|
877
|
-
for (var n = r.split(" "),
|
|
878
|
-
var
|
|
879
|
-
if (
|
|
880
|
-
for (var i = 0; i <
|
|
881
|
-
a.events[n[
|
|
882
|
-
}
|
|
883
|
-
}, e.trigger = function(a, r,
|
|
884
|
-
var n,
|
|
885
|
-
if (i &&
|
|
886
|
-
|
|
1023
|
+
typeof r == "function" && (c = r, r = o.keys(a.events).join(" "));
|
|
1024
|
+
for (var n = r.split(" "), h = 0; h < n.length; h++) {
|
|
1025
|
+
var l = a.events[n[h]], t = [];
|
|
1026
|
+
if (c && l)
|
|
1027
|
+
for (var i = 0; i < l.length; i++) l[i] !== c && t.push(l[i]);
|
|
1028
|
+
a.events[n[h]] = t;
|
|
1029
|
+
}
|
|
1030
|
+
}, e.trigger = function(a, r, c) {
|
|
1031
|
+
var n, h, l, t, i = a.events;
|
|
1032
|
+
if (i && o.keys(i).length > 0) {
|
|
1033
|
+
c || (c = {}), n = r.split(" ");
|
|
887
1034
|
for (var s = 0; s < n.length; s++)
|
|
888
|
-
if (
|
|
889
|
-
t =
|
|
890
|
-
for (var
|
|
1035
|
+
if (h = n[s], l = i[h], l) {
|
|
1036
|
+
t = o.clone(c, !1), t.name = h, t.source = a;
|
|
1037
|
+
for (var u = 0; u < l.length; u++) l[u].apply(a, [t]);
|
|
891
1038
|
}
|
|
892
1039
|
}
|
|
893
1040
|
};
|
|
894
1041
|
})();
|
|
895
1042
|
}),
|
|
896
|
-
(function(
|
|
1043
|
+
(function(T, A, f) {
|
|
897
1044
|
var e = {};
|
|
898
|
-
|
|
899
|
-
var
|
|
1045
|
+
T.exports = e;
|
|
1046
|
+
var o = f(5), a = f(0), r = f(1), c = f(4);
|
|
900
1047
|
(function() {
|
|
901
1048
|
e.create = function(n) {
|
|
902
1049
|
return a.extend({
|
|
@@ -915,16 +1062,16 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
915
1062
|
allComposites: null
|
|
916
1063
|
}
|
|
917
1064
|
}, n);
|
|
918
|
-
}, e.setModified = function(n,
|
|
919
|
-
if (n.isModified =
|
|
1065
|
+
}, e.setModified = function(n, h, l, t) {
|
|
1066
|
+
if (n.isModified = h, h && n.cache && (n.cache.allBodies = null, n.cache.allConstraints = null, n.cache.allComposites = null), l && n.parent && e.setModified(n.parent, h, l, t), t) for (var i = 0; i < n.composites.length; i++) {
|
|
920
1067
|
var s = n.composites[i];
|
|
921
|
-
e.setModified(s,
|
|
1068
|
+
e.setModified(s, h, l, t);
|
|
922
1069
|
}
|
|
923
|
-
}, e.add = function(n,
|
|
924
|
-
var
|
|
925
|
-
|
|
926
|
-
for (var t = 0; t <
|
|
927
|
-
var i =
|
|
1070
|
+
}, e.add = function(n, h) {
|
|
1071
|
+
var l = [].concat(h);
|
|
1072
|
+
o.trigger(n, "beforeAdd", { object: h });
|
|
1073
|
+
for (var t = 0; t < l.length; t++) {
|
|
1074
|
+
var i = l[t];
|
|
928
1075
|
switch (i.type) {
|
|
929
1076
|
case "body":
|
|
930
1077
|
if (i.parent !== i) {
|
|
@@ -944,77 +1091,77 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
944
1091
|
break;
|
|
945
1092
|
}
|
|
946
1093
|
}
|
|
947
|
-
return
|
|
948
|
-
}, e.remove = function(n,
|
|
949
|
-
var t = [].concat(
|
|
950
|
-
|
|
1094
|
+
return o.trigger(n, "afterAdd", { object: h }), n;
|
|
1095
|
+
}, e.remove = function(n, h, l) {
|
|
1096
|
+
var t = [].concat(h);
|
|
1097
|
+
o.trigger(n, "beforeRemove", { object: h });
|
|
951
1098
|
for (var i = 0; i < t.length; i++) {
|
|
952
1099
|
var s = t[i];
|
|
953
1100
|
switch (s.type) {
|
|
954
1101
|
case "body":
|
|
955
|
-
e.removeBody(n, s,
|
|
1102
|
+
e.removeBody(n, s, l);
|
|
956
1103
|
break;
|
|
957
1104
|
case "constraint":
|
|
958
|
-
e.removeConstraint(n, s,
|
|
1105
|
+
e.removeConstraint(n, s, l);
|
|
959
1106
|
break;
|
|
960
1107
|
case "composite":
|
|
961
|
-
e.removeComposite(n, s,
|
|
1108
|
+
e.removeComposite(n, s, l);
|
|
962
1109
|
break;
|
|
963
1110
|
case "mouseConstraint":
|
|
964
1111
|
e.removeConstraint(n, s.constraint);
|
|
965
1112
|
break;
|
|
966
1113
|
}
|
|
967
1114
|
}
|
|
968
|
-
return
|
|
969
|
-
}, e.addComposite = function(n,
|
|
970
|
-
return n.composites.push(
|
|
971
|
-
}, e.removeComposite = function(n,
|
|
972
|
-
var t = a.indexOf(n.composites,
|
|
1115
|
+
return o.trigger(n, "afterRemove", { object: h }), n;
|
|
1116
|
+
}, e.addComposite = function(n, h) {
|
|
1117
|
+
return n.composites.push(h), h.parent = n, e.setModified(n, !0, !0, !1), n;
|
|
1118
|
+
}, e.removeComposite = function(n, h, l) {
|
|
1119
|
+
var t = a.indexOf(n.composites, h);
|
|
973
1120
|
if (t !== -1) {
|
|
974
|
-
var i = e.allBodies(
|
|
1121
|
+
var i = e.allBodies(h);
|
|
975
1122
|
e.removeCompositeAt(n, t);
|
|
976
1123
|
for (var s = 0; s < i.length; s++) i[s].sleepCounter = 0;
|
|
977
1124
|
}
|
|
978
|
-
if (
|
|
1125
|
+
if (l) for (var s = 0; s < n.composites.length; s++) e.removeComposite(n.composites[s], h, !0);
|
|
979
1126
|
return n;
|
|
980
|
-
}, e.removeCompositeAt = function(n,
|
|
981
|
-
return n.composites.splice(
|
|
982
|
-
}, e.addBody = function(n,
|
|
983
|
-
return n.bodies.push(
|
|
984
|
-
}, e.removeBody = function(n,
|
|
985
|
-
var t = a.indexOf(n.bodies,
|
|
986
|
-
if (t !== -1 && (e.removeBodyAt(n, t),
|
|
1127
|
+
}, e.removeCompositeAt = function(n, h) {
|
|
1128
|
+
return n.composites.splice(h, 1), e.setModified(n, !0, !0, !1), n;
|
|
1129
|
+
}, e.addBody = function(n, h) {
|
|
1130
|
+
return n.bodies.push(h), e.setModified(n, !0, !0, !1), n;
|
|
1131
|
+
}, e.removeBody = function(n, h, l) {
|
|
1132
|
+
var t = a.indexOf(n.bodies, h);
|
|
1133
|
+
if (t !== -1 && (e.removeBodyAt(n, t), h.sleepCounter = 0), l) for (var i = 0; i < n.composites.length; i++) e.removeBody(n.composites[i], h, !0);
|
|
987
1134
|
return n;
|
|
988
|
-
}, e.removeBodyAt = function(n,
|
|
989
|
-
return n.bodies.splice(
|
|
990
|
-
}, e.addConstraint = function(n,
|
|
991
|
-
return n.constraints.push(
|
|
992
|
-
}, e.removeConstraint = function(n,
|
|
993
|
-
var t = a.indexOf(n.constraints,
|
|
994
|
-
if (t !== -1 && e.removeConstraintAt(n, t),
|
|
1135
|
+
}, e.removeBodyAt = function(n, h) {
|
|
1136
|
+
return n.bodies.splice(h, 1), e.setModified(n, !0, !0, !1), n;
|
|
1137
|
+
}, e.addConstraint = function(n, h) {
|
|
1138
|
+
return n.constraints.push(h), e.setModified(n, !0, !0, !1), n;
|
|
1139
|
+
}, e.removeConstraint = function(n, h, l) {
|
|
1140
|
+
var t = a.indexOf(n.constraints, h);
|
|
1141
|
+
if (t !== -1 && e.removeConstraintAt(n, t), l) for (var i = 0; i < n.composites.length; i++) e.removeConstraint(n.composites[i], h, !0);
|
|
995
1142
|
return n;
|
|
996
|
-
}, e.removeConstraintAt = function(n,
|
|
997
|
-
return n.constraints.splice(
|
|
998
|
-
}, e.clear = function(n,
|
|
999
|
-
if (
|
|
1000
|
-
return
|
|
1143
|
+
}, e.removeConstraintAt = function(n, h) {
|
|
1144
|
+
return n.constraints.splice(h, 1), e.setModified(n, !0, !0, !1), n;
|
|
1145
|
+
}, e.clear = function(n, h, l) {
|
|
1146
|
+
if (l) for (var t = 0; t < n.composites.length; t++) e.clear(n.composites[t], h, !0);
|
|
1147
|
+
return h ? n.bodies = n.bodies.filter(function(i) {
|
|
1001
1148
|
return i.isStatic;
|
|
1002
1149
|
}) : n.bodies.length = 0, n.constraints.length = 0, n.composites.length = 0, e.setModified(n, !0, !0, !1), n;
|
|
1003
1150
|
}, e.allBodies = function(n) {
|
|
1004
1151
|
if (n.cache && n.cache.allBodies) return n.cache.allBodies;
|
|
1005
|
-
for (var
|
|
1006
|
-
return n.cache && (n.cache.allBodies =
|
|
1152
|
+
for (var h = [].concat(n.bodies), l = 0; l < n.composites.length; l++) h = h.concat(e.allBodies(n.composites[l]));
|
|
1153
|
+
return n.cache && (n.cache.allBodies = h), h;
|
|
1007
1154
|
}, e.allConstraints = function(n) {
|
|
1008
1155
|
if (n.cache && n.cache.allConstraints) return n.cache.allConstraints;
|
|
1009
|
-
for (var
|
|
1010
|
-
return n.cache && (n.cache.allConstraints =
|
|
1156
|
+
for (var h = [].concat(n.constraints), l = 0; l < n.composites.length; l++) h = h.concat(e.allConstraints(n.composites[l]));
|
|
1157
|
+
return n.cache && (n.cache.allConstraints = h), h;
|
|
1011
1158
|
}, e.allComposites = function(n) {
|
|
1012
1159
|
if (n.cache && n.cache.allComposites) return n.cache.allComposites;
|
|
1013
|
-
for (var
|
|
1014
|
-
return n.cache && (n.cache.allComposites =
|
|
1015
|
-
}, e.get = function(n,
|
|
1160
|
+
for (var h = [].concat(n.composites), l = 0; l < n.composites.length; l++) h = h.concat(e.allComposites(n.composites[l]));
|
|
1161
|
+
return n.cache && (n.cache.allComposites = h), h;
|
|
1162
|
+
}, e.get = function(n, h, l) {
|
|
1016
1163
|
var t, i;
|
|
1017
|
-
switch (
|
|
1164
|
+
switch (l) {
|
|
1018
1165
|
case "body":
|
|
1019
1166
|
t = e.allBodies(n);
|
|
1020
1167
|
break;
|
|
@@ -1026,95 +1173,95 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1026
1173
|
break;
|
|
1027
1174
|
}
|
|
1028
1175
|
return t ? (i = t.filter(function(s) {
|
|
1029
|
-
return s.id.toString() ===
|
|
1176
|
+
return s.id.toString() === h.toString();
|
|
1030
1177
|
}), i.length === 0 ? null : i[0]) : null;
|
|
1031
|
-
}, e.move = function(n,
|
|
1032
|
-
return e.remove(n,
|
|
1178
|
+
}, e.move = function(n, h, l) {
|
|
1179
|
+
return e.remove(n, h), e.add(l, h), n;
|
|
1033
1180
|
}, e.rebase = function(n) {
|
|
1034
|
-
for (var
|
|
1181
|
+
for (var h = e.allBodies(n).concat(e.allConstraints(n)).concat(e.allComposites(n)), l = 0; l < h.length; l++) h[l].id = a.nextId();
|
|
1035
1182
|
return n;
|
|
1036
|
-
}, e.translate = function(n,
|
|
1037
|
-
for (var t =
|
|
1183
|
+
}, e.translate = function(n, h, l) {
|
|
1184
|
+
for (var t = l ? e.allBodies(n) : n.bodies, i = 0; i < t.length; i++) c.translate(t[i], h);
|
|
1038
1185
|
return n;
|
|
1039
|
-
}, e.rotate = function(n,
|
|
1040
|
-
for (var i = Math.cos(
|
|
1041
|
-
var x =
|
|
1042
|
-
|
|
1043
|
-
x:
|
|
1044
|
-
y:
|
|
1045
|
-
}),
|
|
1186
|
+
}, e.rotate = function(n, h, l, t) {
|
|
1187
|
+
for (var i = Math.cos(h), s = Math.sin(h), u = t ? e.allBodies(n) : n.bodies, m = 0; m < u.length; m++) {
|
|
1188
|
+
var x = u[m], P = x.position.x - l.x, B = x.position.y - l.y;
|
|
1189
|
+
c.setPosition(x, {
|
|
1190
|
+
x: l.x + (P * i - B * s),
|
|
1191
|
+
y: l.y + (P * s + B * i)
|
|
1192
|
+
}), c.rotate(x, h);
|
|
1046
1193
|
}
|
|
1047
1194
|
return n;
|
|
1048
|
-
}, e.scale = function(n,
|
|
1049
|
-
for (var s = i ? e.allBodies(n) : n.bodies,
|
|
1050
|
-
var m = s[
|
|
1051
|
-
|
|
1052
|
-
x: t.x + x *
|
|
1053
|
-
y: t.y + P *
|
|
1054
|
-
}),
|
|
1195
|
+
}, e.scale = function(n, h, l, t, i) {
|
|
1196
|
+
for (var s = i ? e.allBodies(n) : n.bodies, u = 0; u < s.length; u++) {
|
|
1197
|
+
var m = s[u], x = m.position.x - t.x, P = m.position.y - t.y;
|
|
1198
|
+
c.setPosition(m, {
|
|
1199
|
+
x: t.x + x * h,
|
|
1200
|
+
y: t.y + P * l
|
|
1201
|
+
}), c.scale(m, h, l);
|
|
1055
1202
|
}
|
|
1056
1203
|
return n;
|
|
1057
1204
|
}, e.bounds = function(n) {
|
|
1058
|
-
for (var
|
|
1059
|
-
var i =
|
|
1060
|
-
|
|
1205
|
+
for (var h = e.allBodies(n), l = [], t = 0; t < h.length; t += 1) {
|
|
1206
|
+
var i = h[t];
|
|
1207
|
+
l.push(i.bounds.min, i.bounds.max);
|
|
1061
1208
|
}
|
|
1062
|
-
return r.create(
|
|
1209
|
+
return r.create(l);
|
|
1063
1210
|
};
|
|
1064
1211
|
})();
|
|
1065
1212
|
}),
|
|
1066
|
-
(function(
|
|
1213
|
+
(function(T, A, f) {
|
|
1067
1214
|
var e = {};
|
|
1068
|
-
|
|
1069
|
-
var
|
|
1215
|
+
T.exports = e;
|
|
1216
|
+
var o = f(4), a = f(5), r = f(0);
|
|
1070
1217
|
(function() {
|
|
1071
|
-
e._motionWakeThreshold = 0.18, e._motionSleepThreshold = 0.08, e._minBias = 0.9, e.update = function(
|
|
1072
|
-
for (var
|
|
1073
|
-
var i =
|
|
1218
|
+
e._motionWakeThreshold = 0.18, e._motionSleepThreshold = 0.08, e._minBias = 0.9, e.update = function(c, n) {
|
|
1219
|
+
for (var h = n / r._baseDelta, l = e._motionSleepThreshold, t = 0; t < c.length; t++) {
|
|
1220
|
+
var i = c[t], s = o.getSpeed(i), u = o.getAngularSpeed(i), m = s * s + u * u;
|
|
1074
1221
|
if (i.force.x !== 0 || i.force.y !== 0) {
|
|
1075
1222
|
e.set(i, !1);
|
|
1076
1223
|
continue;
|
|
1077
1224
|
}
|
|
1078
1225
|
var x = Math.min(i.motion, m), P = Math.max(i.motion, m);
|
|
1079
|
-
i.motion = e._minBias * x + (1 - e._minBias) * P, i.sleepThreshold > 0 && i.motion <
|
|
1226
|
+
i.motion = e._minBias * x + (1 - e._minBias) * P, i.sleepThreshold > 0 && i.motion < l ? (i.sleepCounter += 1, i.sleepCounter >= i.sleepThreshold / h && e.set(i, !0)) : i.sleepCounter > 0 && (i.sleepCounter -= 1);
|
|
1080
1227
|
}
|
|
1081
|
-
}, e.afterCollisions = function(
|
|
1082
|
-
for (var n = e._motionSleepThreshold,
|
|
1083
|
-
var
|
|
1084
|
-
if (
|
|
1085
|
-
var t =
|
|
1228
|
+
}, e.afterCollisions = function(c) {
|
|
1229
|
+
for (var n = e._motionSleepThreshold, h = 0; h < c.length; h++) {
|
|
1230
|
+
var l = c[h];
|
|
1231
|
+
if (l.isActive) {
|
|
1232
|
+
var t = l.collision, i = t.bodyA.parent, s = t.bodyB.parent;
|
|
1086
1233
|
if (!(i.isSleeping && s.isSleeping || i.isStatic || s.isStatic) && (i.isSleeping || s.isSleeping)) {
|
|
1087
|
-
var
|
|
1088
|
-
!
|
|
1234
|
+
var u = i.isSleeping && !i.isStatic ? i : s, m = u === i ? s : i;
|
|
1235
|
+
!u.isStatic && m.motion > n && e.set(u, !1);
|
|
1089
1236
|
}
|
|
1090
1237
|
}
|
|
1091
1238
|
}
|
|
1092
|
-
}, e.set = function(
|
|
1093
|
-
var
|
|
1094
|
-
n ? (
|
|
1239
|
+
}, e.set = function(c, n) {
|
|
1240
|
+
var h = c.isSleeping;
|
|
1241
|
+
n ? (c.isSleeping = !0, c.sleepCounter = c.sleepThreshold, c.positionImpulse.x = 0, c.positionImpulse.y = 0, c.positionPrev.x = c.position.x, c.positionPrev.y = c.position.y, c.anglePrev = c.angle, c.speed = 0, c.angularSpeed = 0, c.motion = 0, h || a.trigger(c, "sleepStart")) : (c.isSleeping = !1, c.sleepCounter = 0, h && a.trigger(c, "sleepEnd"));
|
|
1095
1242
|
};
|
|
1096
1243
|
})();
|
|
1097
1244
|
}),
|
|
1098
|
-
(function(
|
|
1245
|
+
(function(T, A, f) {
|
|
1099
1246
|
var e = {};
|
|
1100
|
-
|
|
1101
|
-
var
|
|
1247
|
+
T.exports = e;
|
|
1248
|
+
var o = f(3), a = f(9);
|
|
1102
1249
|
(function() {
|
|
1103
|
-
var r = [],
|
|
1250
|
+
var r = [], c = {
|
|
1104
1251
|
overlap: 0,
|
|
1105
1252
|
axis: null
|
|
1106
1253
|
}, n = {
|
|
1107
1254
|
overlap: 0,
|
|
1108
1255
|
axis: null
|
|
1109
1256
|
};
|
|
1110
|
-
e.create = function(
|
|
1257
|
+
e.create = function(h, l) {
|
|
1111
1258
|
return {
|
|
1112
1259
|
pair: null,
|
|
1113
1260
|
collided: !1,
|
|
1114
|
-
bodyA:
|
|
1115
|
-
bodyB:
|
|
1116
|
-
parentA:
|
|
1117
|
-
parentB:
|
|
1261
|
+
bodyA: h,
|
|
1262
|
+
bodyB: l,
|
|
1263
|
+
parentA: h.parent,
|
|
1264
|
+
parentB: l.parent,
|
|
1118
1265
|
depth: 0,
|
|
1119
1266
|
normal: {
|
|
1120
1267
|
x: 0,
|
|
@@ -1131,56 +1278,56 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1131
1278
|
supports: [null, null],
|
|
1132
1279
|
supportCount: 0
|
|
1133
1280
|
};
|
|
1134
|
-
}, e.collides = function(
|
|
1135
|
-
if (e._overlapAxes(
|
|
1136
|
-
var i = t && t.table[a.id(
|
|
1137
|
-
i ? s = i.collision : (s = e.create(
|
|
1138
|
-
var
|
|
1139
|
-
|
|
1140
|
-
var m = s.normal, x = s.tangent, P = s.penetration,
|
|
1281
|
+
}, e.collides = function(h, l, t) {
|
|
1282
|
+
if (e._overlapAxes(c, h.vertices, l.vertices, h.axes), c.overlap <= 0 || (e._overlapAxes(n, l.vertices, h.vertices, l.axes), n.overlap <= 0)) return null;
|
|
1283
|
+
var i = t && t.table[a.id(h, l)], s;
|
|
1284
|
+
i ? s = i.collision : (s = e.create(h, l), s.collided = !0, s.bodyA = h.id < l.id ? h : l, s.bodyB = h.id < l.id ? l : h, s.parentA = s.bodyA.parent, s.parentB = s.bodyB.parent), h = s.bodyA, l = s.bodyB;
|
|
1285
|
+
var u;
|
|
1286
|
+
c.overlap < n.overlap ? u = c : u = n;
|
|
1287
|
+
var m = s.normal, x = s.tangent, P = s.penetration, B = s.supports, g = u.overlap, p = u.axis, y = p.x, v = p.y, w = l.position.x - h.position.x, S = l.position.y - h.position.y;
|
|
1141
1288
|
y * w + v * S >= 0 && (y = -y, v = -v), m.x = y, m.y = v, x.x = -v, x.y = y, P.x = y * g, P.y = v * g, s.depth = g;
|
|
1142
|
-
var C = e._findSupports(
|
|
1143
|
-
if (
|
|
1144
|
-
var I = e._findSupports(
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
return M === 0 && (
|
|
1148
|
-
}, e._overlapAxes = function(
|
|
1149
|
-
var s =
|
|
1289
|
+
var C = e._findSupports(h, l, m, 1), M = 0;
|
|
1290
|
+
if (o.contains(h.vertices, C[0]) && (B[M++] = C[0]), o.contains(h.vertices, C[1]) && (B[M++] = C[1]), M < 2) {
|
|
1291
|
+
var I = e._findSupports(l, h, m, -1);
|
|
1292
|
+
o.contains(l.vertices, I[0]) && (B[M++] = I[0]), M < 2 && o.contains(l.vertices, I[1]) && (B[M++] = I[1]);
|
|
1293
|
+
}
|
|
1294
|
+
return M === 0 && (B[M++] = C[0]), s.supportCount = M, s;
|
|
1295
|
+
}, e._overlapAxes = function(h, l, t, i) {
|
|
1296
|
+
var s = l.length, u = t.length, m = l[0].x, x = l[0].y, P = t[0].x, B = t[0].y, g = i.length, p = Number.MAX_VALUE, y = 0, v, w, S, C, M, I;
|
|
1150
1297
|
for (M = 0; M < g; M++) {
|
|
1151
|
-
var R = i[M], L = R.x,
|
|
1298
|
+
var R = i[M], L = R.x, b = R.y, k = m * L + x * b, D = P * L + B * b, F = k, H = D;
|
|
1152
1299
|
for (I = 1; I < s; I += 1)
|
|
1153
|
-
C =
|
|
1154
|
-
for (I = 1; I <
|
|
1155
|
-
C = t[I].x * L + t[I].y *
|
|
1156
|
-
if (w =
|
|
1300
|
+
C = l[I].x * L + l[I].y * b, C > F ? F = C : C < k && (k = C);
|
|
1301
|
+
for (I = 1; I < u; I += 1)
|
|
1302
|
+
C = t[I].x * L + t[I].y * b, C > H ? H = C : C < D && (D = C);
|
|
1303
|
+
if (w = F - D, S = H - k, v = w < S ? w : S, v < p && (p = v, y = M, v <= 0))
|
|
1157
1304
|
break;
|
|
1158
1305
|
}
|
|
1159
|
-
|
|
1160
|
-
}, e._findSupports = function(
|
|
1161
|
-
var s =
|
|
1162
|
-
for (S = 1; S <
|
|
1163
|
-
p = s[S], w = P * (m - p.x) +
|
|
1164
|
-
return v = s[(
|
|
1306
|
+
h.axis = i[y], h.overlap = p;
|
|
1307
|
+
}, e._findSupports = function(h, l, t, i) {
|
|
1308
|
+
var s = l.vertices, u = s.length, m = h.position.x, x = h.position.y, P = t.x * i, B = t.y * i, g = s[0], p = g, y = P * (m - p.x) + B * (x - p.y), v, w, S;
|
|
1309
|
+
for (S = 1; S < u; S += 1)
|
|
1310
|
+
p = s[S], w = P * (m - p.x) + B * (x - p.y), w < y && (y = w, g = p);
|
|
1311
|
+
return v = s[(u + g.index - 1) % u], y = P * (m - v.x) + B * (x - v.y), p = s[(g.index + 1) % u], P * (m - p.x) + B * (x - p.y) < y ? (r[0] = g, r[1] = p, r) : (r[0] = g, r[1] = v, r);
|
|
1165
1312
|
};
|
|
1166
1313
|
})();
|
|
1167
1314
|
}),
|
|
1168
|
-
(function(
|
|
1315
|
+
(function(T, A, f) {
|
|
1169
1316
|
var e = {};
|
|
1170
|
-
|
|
1171
|
-
var
|
|
1317
|
+
T.exports = e;
|
|
1318
|
+
var o = f(16);
|
|
1172
1319
|
(function() {
|
|
1173
1320
|
e.create = function(a, r) {
|
|
1174
|
-
var
|
|
1175
|
-
id: e.id(
|
|
1176
|
-
bodyA:
|
|
1321
|
+
var c = a.bodyA, n = a.bodyB, h = {
|
|
1322
|
+
id: e.id(c, n),
|
|
1323
|
+
bodyA: c,
|
|
1177
1324
|
bodyB: n,
|
|
1178
1325
|
collision: a,
|
|
1179
|
-
contacts: [
|
|
1326
|
+
contacts: [o.create(), o.create()],
|
|
1180
1327
|
contactCount: 0,
|
|
1181
1328
|
separation: 0,
|
|
1182
1329
|
isActive: !0,
|
|
1183
|
-
isSensor:
|
|
1330
|
+
isSensor: c.isSensor || n.isSensor,
|
|
1184
1331
|
timeCreated: r,
|
|
1185
1332
|
timeUpdated: r,
|
|
1186
1333
|
inverseMass: 0,
|
|
@@ -1189,26 +1336,26 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1189
1336
|
restitution: 0,
|
|
1190
1337
|
slop: 0
|
|
1191
1338
|
};
|
|
1192
|
-
return e.update(
|
|
1193
|
-
}, e.update = function(a, r,
|
|
1194
|
-
var n = r.supports,
|
|
1195
|
-
a.isActive = !0, a.timeUpdated =
|
|
1196
|
-
var s = n[0],
|
|
1197
|
-
(x.vertex === s ||
|
|
1198
|
-
}, e.setActive = function(a, r,
|
|
1199
|
-
r ? (a.isActive = !0, a.timeUpdated =
|
|
1339
|
+
return e.update(h, a, r), h;
|
|
1340
|
+
}, e.update = function(a, r, c) {
|
|
1341
|
+
var n = r.supports, h = r.supportCount, l = a.contacts, t = r.parentA, i = r.parentB;
|
|
1342
|
+
a.isActive = !0, a.timeUpdated = c, a.collision = r, a.separation = r.depth, a.inverseMass = t.inverseMass + i.inverseMass, a.friction = t.friction < i.friction ? t.friction : i.friction, a.frictionStatic = t.frictionStatic > i.frictionStatic ? t.frictionStatic : i.frictionStatic, a.restitution = t.restitution > i.restitution ? t.restitution : i.restitution, a.slop = t.slop > i.slop ? t.slop : i.slop, a.contactCount = h, r.pair = a;
|
|
1343
|
+
var s = n[0], u = l[0], m = n[1], x = l[1];
|
|
1344
|
+
(x.vertex === s || u.vertex === m) && (l[1] = u, l[0] = u = x, x = l[1]), u.vertex = s, x.vertex = m;
|
|
1345
|
+
}, e.setActive = function(a, r, c) {
|
|
1346
|
+
r ? (a.isActive = !0, a.timeUpdated = c) : (a.isActive = !1, a.contactCount = 0);
|
|
1200
1347
|
}, e.id = function(a, r) {
|
|
1201
1348
|
return a.id < r.id ? a.id.toString(36) + ":" + r.id.toString(36) : r.id.toString(36) + ":" + a.id.toString(36);
|
|
1202
1349
|
};
|
|
1203
1350
|
})();
|
|
1204
1351
|
}),
|
|
1205
|
-
(function(
|
|
1352
|
+
(function(T, A, f) {
|
|
1206
1353
|
var e = {};
|
|
1207
|
-
|
|
1208
|
-
var
|
|
1354
|
+
T.exports = e;
|
|
1355
|
+
var o = f(3), a = f(2), r = f(7), c = f(1), n = f(11), h = f(0);
|
|
1209
1356
|
(function() {
|
|
1210
|
-
e._warming = 0.4, e._torqueDampen = 1, e._minLength = 1e-6, e.create = function(
|
|
1211
|
-
var t =
|
|
1357
|
+
e._warming = 0.4, e._torqueDampen = 1, e._minLength = 1e-6, e.create = function(l) {
|
|
1358
|
+
var t = l;
|
|
1212
1359
|
t.bodyA && !t.pointA && (t.pointA = {
|
|
1213
1360
|
x: 0,
|
|
1214
1361
|
y: 0
|
|
@@ -1216,8 +1363,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1216
1363
|
x: 0,
|
|
1217
1364
|
y: 0
|
|
1218
1365
|
});
|
|
1219
|
-
var i = t.bodyA ? a.add(t.bodyA.position, t.pointA) : t.pointA, s = t.bodyB ? a.add(t.bodyB.position, t.pointB) : t.pointB,
|
|
1220
|
-
t.length = typeof t.length < "u" ? t.length :
|
|
1366
|
+
var i = t.bodyA ? a.add(t.bodyA.position, t.pointA) : t.pointA, s = t.bodyB ? a.add(t.bodyB.position, t.pointB) : t.pointB, u = a.magnitude(a.sub(i, s));
|
|
1367
|
+
t.length = typeof t.length < "u" ? t.length : u, t.id = t.id || h.nextId(), t.label = t.label || "Constraint", t.type = "constraint", t.stiffness = t.stiffness || (t.length > 0 ? 1 : 0.7), t.damping = t.damping || 0, t.angularStiffness = t.angularStiffness || 0, t.angleA = t.bodyA ? t.bodyA.angle : t.angleA, t.angleB = t.bodyB ? t.bodyB.angle : t.angleB, t.plugin = {};
|
|
1221
1368
|
var m = {
|
|
1222
1369
|
visible: !0,
|
|
1223
1370
|
lineWidth: 2,
|
|
@@ -1225,238 +1372,238 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1225
1372
|
type: "line",
|
|
1226
1373
|
anchors: !0
|
|
1227
1374
|
};
|
|
1228
|
-
return t.length === 0 && t.stiffness > 0.1 ? (m.type = "pin", m.anchors = !1) : t.stiffness < 0.9 && (m.type = "spring"), t.render =
|
|
1229
|
-
}, e.preSolveAll = function(
|
|
1230
|
-
for (var t = 0; t <
|
|
1231
|
-
var i =
|
|
1375
|
+
return t.length === 0 && t.stiffness > 0.1 ? (m.type = "pin", m.anchors = !1) : t.stiffness < 0.9 && (m.type = "spring"), t.render = h.extend(m, t.render), t;
|
|
1376
|
+
}, e.preSolveAll = function(l) {
|
|
1377
|
+
for (var t = 0; t < l.length; t += 1) {
|
|
1378
|
+
var i = l[t], s = i.constraintImpulse;
|
|
1232
1379
|
i.isStatic || s.x === 0 && s.y === 0 && s.angle === 0 || (i.position.x += s.x, i.position.y += s.y, i.angle += s.angle);
|
|
1233
1380
|
}
|
|
1234
|
-
}, e.solveAll = function(
|
|
1235
|
-
for (var i =
|
|
1236
|
-
var
|
|
1237
|
-
(m || x) && e.solve(
|
|
1381
|
+
}, e.solveAll = function(l, t) {
|
|
1382
|
+
for (var i = h.clamp(t / h._baseDelta, 0, 1), s = 0; s < l.length; s += 1) {
|
|
1383
|
+
var u = l[s], m = !u.bodyA || u.bodyA && u.bodyA.isStatic, x = !u.bodyB || u.bodyB && u.bodyB.isStatic;
|
|
1384
|
+
(m || x) && e.solve(l[s], i);
|
|
1238
1385
|
}
|
|
1239
|
-
for (s = 0; s <
|
|
1240
|
-
|
|
1241
|
-
}, e.solve = function(
|
|
1242
|
-
var i =
|
|
1386
|
+
for (s = 0; s < l.length; s += 1)
|
|
1387
|
+
u = l[s], m = !u.bodyA || u.bodyA && u.bodyA.isStatic, x = !u.bodyB || u.bodyB && u.bodyB.isStatic, !m && !x && e.solve(l[s], i);
|
|
1388
|
+
}, e.solve = function(l, t) {
|
|
1389
|
+
var i = l.bodyA, s = l.bodyB, u = l.pointA, m = l.pointB;
|
|
1243
1390
|
if (!(!i && !s)) {
|
|
1244
|
-
i && !i.isStatic && (a.rotate(
|
|
1245
|
-
var x =
|
|
1246
|
-
if (i && (x = a.add(i.position,
|
|
1247
|
-
var
|
|
1391
|
+
i && !i.isStatic && (a.rotate(u, i.angle - l.angleA, u), l.angleA = i.angle), s && !s.isStatic && (a.rotate(m, s.angle - l.angleB, m), l.angleB = s.angle);
|
|
1392
|
+
var x = u, P = m;
|
|
1393
|
+
if (i && (x = a.add(i.position, u)), s && (P = a.add(s.position, m)), !(!x || !P)) {
|
|
1394
|
+
var B = a.sub(x, P), g = a.magnitude(B);
|
|
1248
1395
|
g < e._minLength && (g = e._minLength);
|
|
1249
|
-
var p = (g -
|
|
1396
|
+
var p = (g - l.length) / g, y = l.stiffness >= 1 || l.length === 0 ? l.stiffness * t : l.stiffness * t * t, v = l.damping * t, w = a.mult(B, p * y), S = (i ? i.inverseMass : 0) + (s ? s.inverseMass : 0), C = S + ((i ? i.inverseInertia : 0) + (s ? s.inverseInertia : 0)), M, I, R, L, b;
|
|
1250
1397
|
if (v > 0) {
|
|
1251
1398
|
var k = a.create();
|
|
1252
|
-
R = a.div(
|
|
1399
|
+
R = a.div(B, g), b = a.sub(s && a.sub(s.position, s.positionPrev) || k, i && a.sub(i.position, i.positionPrev) || k), L = a.dot(R, b);
|
|
1253
1400
|
}
|
|
1254
|
-
i && !i.isStatic && (I = i.inverseMass / S, i.constraintImpulse.x -= w.x * I, i.constraintImpulse.y -= w.y * I, i.position.x -= w.x * I, i.position.y -= w.y * I, v > 0 && (i.positionPrev.x -= v * R.x * L * I, i.positionPrev.y -= v * R.y * L * I), M = a.cross(
|
|
1401
|
+
i && !i.isStatic && (I = i.inverseMass / S, i.constraintImpulse.x -= w.x * I, i.constraintImpulse.y -= w.y * I, i.position.x -= w.x * I, i.position.y -= w.y * I, v > 0 && (i.positionPrev.x -= v * R.x * L * I, i.positionPrev.y -= v * R.y * L * I), M = a.cross(u, w) / C * e._torqueDampen * i.inverseInertia * (1 - l.angularStiffness), i.constraintImpulse.angle -= M, i.angle -= M), s && !s.isStatic && (I = s.inverseMass / S, s.constraintImpulse.x += w.x * I, s.constraintImpulse.y += w.y * I, s.position.x += w.x * I, s.position.y += w.y * I, v > 0 && (s.positionPrev.x += v * R.x * L * I, s.positionPrev.y += v * R.y * L * I), M = a.cross(m, w) / C * e._torqueDampen * s.inverseInertia * (1 - l.angularStiffness), s.constraintImpulse.angle += M, s.angle += M);
|
|
1255
1402
|
}
|
|
1256
1403
|
}
|
|
1257
|
-
}, e.postSolveAll = function(
|
|
1258
|
-
for (var t = 0; t <
|
|
1259
|
-
var i =
|
|
1404
|
+
}, e.postSolveAll = function(l) {
|
|
1405
|
+
for (var t = 0; t < l.length; t++) {
|
|
1406
|
+
var i = l[t], s = i.constraintImpulse;
|
|
1260
1407
|
if (!(i.isStatic || s.x === 0 && s.y === 0 && s.angle === 0)) {
|
|
1261
1408
|
r.set(i, !1);
|
|
1262
|
-
for (var
|
|
1263
|
-
var m = i.parts[
|
|
1264
|
-
|
|
1409
|
+
for (var u = 0; u < i.parts.length; u++) {
|
|
1410
|
+
var m = i.parts[u];
|
|
1411
|
+
o.translate(m.vertices, s), u > 0 && (m.position.x += s.x, m.position.y += s.y), s.angle !== 0 && (o.rotate(m.vertices, s.angle, i.position), n.rotate(m.axes, s.angle), u > 0 && a.rotateAbout(m.position, s.angle, i.position, m.position)), c.update(m.bounds, m.vertices, i.velocity);
|
|
1265
1412
|
}
|
|
1266
1413
|
s.angle *= e._warming, s.x *= e._warming, s.y *= e._warming;
|
|
1267
1414
|
}
|
|
1268
1415
|
}
|
|
1269
|
-
}, e.pointAWorld = function(
|
|
1416
|
+
}, e.pointAWorld = function(l) {
|
|
1270
1417
|
return {
|
|
1271
|
-
x: (
|
|
1272
|
-
y: (
|
|
1418
|
+
x: (l.bodyA ? l.bodyA.position.x : 0) + (l.pointA ? l.pointA.x : 0),
|
|
1419
|
+
y: (l.bodyA ? l.bodyA.position.y : 0) + (l.pointA ? l.pointA.y : 0)
|
|
1273
1420
|
};
|
|
1274
|
-
}, e.pointBWorld = function(
|
|
1421
|
+
}, e.pointBWorld = function(l) {
|
|
1275
1422
|
return {
|
|
1276
|
-
x: (
|
|
1277
|
-
y: (
|
|
1423
|
+
x: (l.bodyB ? l.bodyB.position.x : 0) + (l.pointB ? l.pointB.x : 0),
|
|
1424
|
+
y: (l.bodyB ? l.bodyB.position.y : 0) + (l.pointB ? l.pointB.y : 0)
|
|
1278
1425
|
};
|
|
1279
|
-
}, e.currentLength = function(
|
|
1280
|
-
var t = (
|
|
1426
|
+
}, e.currentLength = function(l) {
|
|
1427
|
+
var t = (l.bodyA ? l.bodyA.position.x : 0) + (l.pointA ? l.pointA.x : 0), i = (l.bodyA ? l.bodyA.position.y : 0) + (l.pointA ? l.pointA.y : 0), s = (l.bodyB ? l.bodyB.position.x : 0) + (l.pointB ? l.pointB.x : 0), u = (l.bodyB ? l.bodyB.position.y : 0) + (l.pointB ? l.pointB.y : 0), m = t - s, x = i - u;
|
|
1281
1428
|
return Math.sqrt(m * m + x * x);
|
|
1282
1429
|
};
|
|
1283
1430
|
})();
|
|
1284
1431
|
}),
|
|
1285
|
-
(function(
|
|
1432
|
+
(function(T, A, f) {
|
|
1286
1433
|
var e = {};
|
|
1287
|
-
|
|
1288
|
-
var
|
|
1434
|
+
T.exports = e;
|
|
1435
|
+
var o = f(2), a = f(0);
|
|
1289
1436
|
(function() {
|
|
1290
1437
|
e.fromVertices = function(r) {
|
|
1291
|
-
for (var
|
|
1292
|
-
var
|
|
1293
|
-
x: r[
|
|
1294
|
-
y: r[n].x - r[
|
|
1295
|
-
}), t =
|
|
1296
|
-
t = t.toFixed(3).toString(),
|
|
1297
|
-
}
|
|
1298
|
-
return a.values(
|
|
1299
|
-
}, e.rotate = function(r,
|
|
1300
|
-
if (
|
|
1301
|
-
for (var n = Math.cos(
|
|
1302
|
-
var t = r[
|
|
1303
|
-
t.y = t.x *
|
|
1438
|
+
for (var c = {}, n = 0; n < r.length; n++) {
|
|
1439
|
+
var h = (n + 1) % r.length, l = o.normalise({
|
|
1440
|
+
x: r[h].y - r[n].y,
|
|
1441
|
+
y: r[n].x - r[h].x
|
|
1442
|
+
}), t = l.y === 0 ? 1 / 0 : l.x / l.y;
|
|
1443
|
+
t = t.toFixed(3).toString(), c[t] = l;
|
|
1444
|
+
}
|
|
1445
|
+
return a.values(c);
|
|
1446
|
+
}, e.rotate = function(r, c) {
|
|
1447
|
+
if (c !== 0)
|
|
1448
|
+
for (var n = Math.cos(c), h = Math.sin(c), l = 0; l < r.length; l++) {
|
|
1449
|
+
var t = r[l], i = t.x * n - t.y * h;
|
|
1450
|
+
t.y = t.x * h + t.y * n, t.x = i;
|
|
1304
1451
|
}
|
|
1305
1452
|
};
|
|
1306
1453
|
})();
|
|
1307
1454
|
}),
|
|
1308
|
-
(function(
|
|
1455
|
+
(function(T, A, f) {
|
|
1309
1456
|
var e = {};
|
|
1310
|
-
|
|
1311
|
-
var
|
|
1457
|
+
T.exports = e;
|
|
1458
|
+
var o = f(3), a = f(0), r = f(4), c = f(1), n = f(2);
|
|
1312
1459
|
(function() {
|
|
1313
|
-
e.rectangle = function(
|
|
1460
|
+
e.rectangle = function(h, l, t, i, s) {
|
|
1314
1461
|
s = s || {};
|
|
1315
|
-
var
|
|
1462
|
+
var u = {
|
|
1316
1463
|
label: "Rectangle Body",
|
|
1317
1464
|
position: {
|
|
1318
|
-
x:
|
|
1319
|
-
y:
|
|
1465
|
+
x: h,
|
|
1466
|
+
y: l
|
|
1320
1467
|
},
|
|
1321
|
-
vertices:
|
|
1468
|
+
vertices: o.fromPath("L 0 0 L " + t + " 0 L " + t + " " + i + " L 0 " + i)
|
|
1322
1469
|
};
|
|
1323
1470
|
if (s.chamfer) {
|
|
1324
1471
|
var m = s.chamfer;
|
|
1325
|
-
|
|
1472
|
+
u.vertices = o.chamfer(u.vertices, m.radius, m.quality, m.qualityMin, m.qualityMax), delete s.chamfer;
|
|
1326
1473
|
}
|
|
1327
|
-
return r.create(a.extend({},
|
|
1328
|
-
}, e.trapezoid = function(
|
|
1329
|
-
|
|
1330
|
-
var m = (1 - s * 2) * t, x = t * s, P = x + m,
|
|
1331
|
-
s < 0.5 ? g = "L 0 0 L " + x + " " + -i + " L " + P + " " + -i + " L " +
|
|
1474
|
+
return r.create(a.extend({}, u, s));
|
|
1475
|
+
}, e.trapezoid = function(h, l, t, i, s, u) {
|
|
1476
|
+
u = u || {}, s >= 1 && a.warn("Bodies.trapezoid: slope parameter must be < 1."), s *= 0.5;
|
|
1477
|
+
var m = (1 - s * 2) * t, x = t * s, P = x + m, B = P + x, g;
|
|
1478
|
+
s < 0.5 ? g = "L 0 0 L " + x + " " + -i + " L " + P + " " + -i + " L " + B + " 0" : g = "L 0 0 L " + P + " " + -i + " L " + B + " 0";
|
|
1332
1479
|
var p = {
|
|
1333
1480
|
label: "Trapezoid Body",
|
|
1334
1481
|
position: {
|
|
1335
|
-
x:
|
|
1336
|
-
y:
|
|
1482
|
+
x: h,
|
|
1483
|
+
y: l
|
|
1337
1484
|
},
|
|
1338
|
-
vertices:
|
|
1485
|
+
vertices: o.fromPath(g)
|
|
1339
1486
|
};
|
|
1340
|
-
if (
|
|
1341
|
-
var y =
|
|
1342
|
-
p.vertices =
|
|
1487
|
+
if (u.chamfer) {
|
|
1488
|
+
var y = u.chamfer;
|
|
1489
|
+
p.vertices = o.chamfer(p.vertices, y.radius, y.quality, y.qualityMin, y.qualityMax), delete u.chamfer;
|
|
1343
1490
|
}
|
|
1344
|
-
return r.create(a.extend({}, p,
|
|
1345
|
-
}, e.circle = function(
|
|
1491
|
+
return r.create(a.extend({}, p, u));
|
|
1492
|
+
}, e.circle = function(h, l, t, i, s) {
|
|
1346
1493
|
i = i || {};
|
|
1347
|
-
var
|
|
1494
|
+
var u = {
|
|
1348
1495
|
label: "Circle Body",
|
|
1349
1496
|
circleRadius: t
|
|
1350
1497
|
};
|
|
1351
1498
|
s = s || 25;
|
|
1352
1499
|
var m = Math.ceil(Math.max(10, Math.min(s, t)));
|
|
1353
|
-
return m % 2 === 1 && (m += 1), e.polygon(
|
|
1354
|
-
}, e.polygon = function(
|
|
1355
|
-
if (s = s || {}, t < 3) return e.circle(
|
|
1356
|
-
for (var
|
|
1357
|
-
var
|
|
1500
|
+
return m % 2 === 1 && (m += 1), e.polygon(h, l, m, t, a.extend({}, u, i));
|
|
1501
|
+
}, e.polygon = function(h, l, t, i, s) {
|
|
1502
|
+
if (s = s || {}, t < 3) return e.circle(h, l, i, s);
|
|
1503
|
+
for (var u = 2 * Math.PI / t, m = "", x = u * 0.5, P = 0; P < t; P += 1) {
|
|
1504
|
+
var B = x + P * u, g = Math.cos(B) * i, p = Math.sin(B) * i;
|
|
1358
1505
|
m += "L " + g.toFixed(3) + " " + p.toFixed(3) + " ";
|
|
1359
1506
|
}
|
|
1360
1507
|
var y = {
|
|
1361
1508
|
label: "Polygon Body",
|
|
1362
1509
|
position: {
|
|
1363
|
-
x:
|
|
1364
|
-
y:
|
|
1510
|
+
x: h,
|
|
1511
|
+
y: l
|
|
1365
1512
|
},
|
|
1366
|
-
vertices:
|
|
1513
|
+
vertices: o.fromPath(m)
|
|
1367
1514
|
};
|
|
1368
1515
|
if (s.chamfer) {
|
|
1369
1516
|
var v = s.chamfer;
|
|
1370
|
-
y.vertices =
|
|
1517
|
+
y.vertices = o.chamfer(y.vertices, v.radius, v.quality, v.qualityMin, v.qualityMax), delete s.chamfer;
|
|
1371
1518
|
}
|
|
1372
1519
|
return r.create(a.extend({}, y, s));
|
|
1373
|
-
}, e.fromVertices = function(
|
|
1374
|
-
var P = a.getDecomp(),
|
|
1375
|
-
for (i = i || {}, p = [], s = typeof s < "u" ? s : !1,
|
|
1376
|
-
if (w = t[I], y =
|
|
1377
|
-
y ? w =
|
|
1520
|
+
}, e.fromVertices = function(h, l, t, i, s, u, m, x) {
|
|
1521
|
+
var P = a.getDecomp(), B = !!(P && P.quickDecomp), g, p, y, v, w, S, C, M, I, R;
|
|
1522
|
+
for (i = i || {}, p = [], s = typeof s < "u" ? s : !1, u = typeof u < "u" ? u : 0.01, m = typeof m < "u" ? m : 10, x = typeof x < "u" ? x : 0.01, a.isArray(t[0]) || (t = [t]), I = 0; I < t.length; I += 1)
|
|
1523
|
+
if (w = t[I], y = o.isConvex(w), v = !y, v && !B && a.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."), y || !B)
|
|
1524
|
+
y ? w = o.clockwiseSort(w) : w = o.hull(w), p.push({
|
|
1378
1525
|
position: {
|
|
1379
|
-
x:
|
|
1380
|
-
y:
|
|
1526
|
+
x: h,
|
|
1527
|
+
y: l
|
|
1381
1528
|
},
|
|
1382
1529
|
vertices: w
|
|
1383
1530
|
});
|
|
1384
1531
|
else {
|
|
1385
|
-
var L = w.map(function(
|
|
1386
|
-
return [
|
|
1532
|
+
var L = w.map(function(U) {
|
|
1533
|
+
return [U.x, U.y];
|
|
1387
1534
|
});
|
|
1388
|
-
P.makeCCW(L),
|
|
1389
|
-
var
|
|
1390
|
-
for (S = 0; S <
|
|
1391
|
-
var k =
|
|
1535
|
+
P.makeCCW(L), u !== !1 && P.removeCollinearPoints(L, u), x !== !1 && P.removeDuplicatePoints && P.removeDuplicatePoints(L, x);
|
|
1536
|
+
var b = P.quickDecomp(L);
|
|
1537
|
+
for (S = 0; S < b.length; S++) {
|
|
1538
|
+
var k = b[S].map(function(U) {
|
|
1392
1539
|
return {
|
|
1393
|
-
x:
|
|
1394
|
-
y:
|
|
1540
|
+
x: U[0],
|
|
1541
|
+
y: U[1]
|
|
1395
1542
|
};
|
|
1396
1543
|
});
|
|
1397
|
-
m > 0 &&
|
|
1398
|
-
position:
|
|
1544
|
+
m > 0 && o.area(k) < m || p.push({
|
|
1545
|
+
position: o.centre(k),
|
|
1399
1546
|
vertices: k
|
|
1400
1547
|
});
|
|
1401
1548
|
}
|
|
1402
1549
|
}
|
|
1403
1550
|
for (S = 0; S < p.length; S++) p[S] = r.create(a.extend(p[S], i));
|
|
1404
1551
|
if (s) {
|
|
1405
|
-
var
|
|
1552
|
+
var D = 5;
|
|
1406
1553
|
for (S = 0; S < p.length; S++) {
|
|
1407
|
-
var
|
|
1554
|
+
var F = p[S];
|
|
1408
1555
|
for (C = S + 1; C < p.length; C++) {
|
|
1409
|
-
var
|
|
1410
|
-
if (
|
|
1411
|
-
var G =
|
|
1412
|
-
for (M = 0; M <
|
|
1413
|
-
var Q = n.magnitudeSquared(n.sub(G[(M + 1) % G.length],
|
|
1414
|
-
Q <
|
|
1556
|
+
var H = p[C];
|
|
1557
|
+
if (c.overlaps(F.bounds, H.bounds)) {
|
|
1558
|
+
var G = F.vertices, V = H.vertices;
|
|
1559
|
+
for (M = 0; M < F.vertices.length; M++) for (R = 0; R < H.vertices.length; R++) {
|
|
1560
|
+
var Q = n.magnitudeSquared(n.sub(G[(M + 1) % G.length], V[R])), X = n.magnitudeSquared(n.sub(G[M], V[(R + 1) % V.length]));
|
|
1561
|
+
Q < D && X < D && (G[M].isInternal = !0, V[R].isInternal = !0);
|
|
1415
1562
|
}
|
|
1416
1563
|
}
|
|
1417
1564
|
}
|
|
1418
1565
|
}
|
|
1419
1566
|
}
|
|
1420
1567
|
return p.length > 1 ? (g = r.create(a.extend({ parts: p.slice(0) }, i)), r.setPosition(g, {
|
|
1421
|
-
x:
|
|
1422
|
-
y:
|
|
1568
|
+
x: h,
|
|
1569
|
+
y: l
|
|
1423
1570
|
}), g) : p[0];
|
|
1424
1571
|
};
|
|
1425
1572
|
})();
|
|
1426
1573
|
}),
|
|
1427
|
-
(function(
|
|
1574
|
+
(function(T, A, f) {
|
|
1428
1575
|
var e = {};
|
|
1429
|
-
|
|
1430
|
-
var
|
|
1576
|
+
T.exports = e;
|
|
1577
|
+
var o = f(0), a = f(8);
|
|
1431
1578
|
(function() {
|
|
1432
1579
|
e.create = function(r) {
|
|
1433
|
-
return
|
|
1580
|
+
return o.extend({
|
|
1434
1581
|
bodies: [],
|
|
1435
1582
|
collisions: [],
|
|
1436
1583
|
pairs: null
|
|
1437
1584
|
}, r);
|
|
1438
|
-
}, e.setBodies = function(r,
|
|
1439
|
-
r.bodies =
|
|
1585
|
+
}, e.setBodies = function(r, c) {
|
|
1586
|
+
r.bodies = c.slice(0);
|
|
1440
1587
|
}, e.clear = function(r) {
|
|
1441
1588
|
r.bodies = [], r.collisions = [];
|
|
1442
1589
|
}, e.collisions = function(r) {
|
|
1443
|
-
var
|
|
1444
|
-
for (n.sort(e._compareBoundsX),
|
|
1445
|
-
var x = n[
|
|
1446
|
-
for (m =
|
|
1590
|
+
var c = r.pairs, n = r.bodies, h = n.length, l = e.canCollide, t = a.collides, i = r.collisions, s = 0, u, m;
|
|
1591
|
+
for (n.sort(e._compareBoundsX), u = 0; u < h; u++) {
|
|
1592
|
+
var x = n[u], P = x.bounds, B = x.bounds.max.x, g = x.bounds.max.y, p = x.bounds.min.y, y = x.isStatic || x.isSleeping, v = x.parts.length, w = v === 1;
|
|
1593
|
+
for (m = u + 1; m < h; m++) {
|
|
1447
1594
|
var S = n[m], C = S.bounds;
|
|
1448
|
-
if (C.min.x >
|
|
1449
|
-
if (!(g < C.min.y || p > C.max.y) && !(y && (S.isStatic || S.isSleeping)) &&
|
|
1595
|
+
if (C.min.x > B) break;
|
|
1596
|
+
if (!(g < C.min.y || p > C.max.y) && !(y && (S.isStatic || S.isSleeping)) && l(x.collisionFilter, S.collisionFilter)) {
|
|
1450
1597
|
var M = S.parts.length;
|
|
1451
1598
|
if (w && M === 1) {
|
|
1452
|
-
var I = t(x, S,
|
|
1599
|
+
var I = t(x, S, c);
|
|
1453
1600
|
I && (i[s++] = I);
|
|
1454
1601
|
} else
|
|
1455
|
-
for (var R = v > 1 ? 1 : 0, L = M > 1 ? 1 : 0,
|
|
1456
|
-
for (var k = x.parts[
|
|
1457
|
-
var
|
|
1602
|
+
for (var R = v > 1 ? 1 : 0, L = M > 1 ? 1 : 0, b = R; b < v; b++)
|
|
1603
|
+
for (var k = x.parts[b], P = k.bounds, D = L; D < M; D++) {
|
|
1604
|
+
var F = S.parts[D], C = F.bounds;
|
|
1458
1605
|
if (!(P.min.x > C.max.x || P.max.x < C.min.x || P.max.y < C.min.y || P.min.y > C.max.y)) {
|
|
1459
|
-
var I = t(k,
|
|
1606
|
+
var I = t(k, F, c);
|
|
1460
1607
|
I && (i[s++] = I);
|
|
1461
1608
|
}
|
|
1462
1609
|
}
|
|
@@ -1464,21 +1611,21 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1464
1611
|
}
|
|
1465
1612
|
}
|
|
1466
1613
|
return i.length !== s && (i.length = s), i;
|
|
1467
|
-
}, e.canCollide = function(r,
|
|
1468
|
-
return r.group ===
|
|
1469
|
-
}, e._compareBoundsX = function(r,
|
|
1470
|
-
return r.bounds.min.x -
|
|
1614
|
+
}, e.canCollide = function(r, c) {
|
|
1615
|
+
return r.group === c.group && r.group !== 0 ? r.group > 0 : (r.mask & c.category) !== 0 && (c.mask & r.category) !== 0;
|
|
1616
|
+
}, e._compareBoundsX = function(r, c) {
|
|
1617
|
+
return r.bounds.min.x - c.bounds.min.x;
|
|
1471
1618
|
};
|
|
1472
1619
|
})();
|
|
1473
1620
|
}),
|
|
1474
|
-
(function(
|
|
1621
|
+
(function(T, A, f) {
|
|
1475
1622
|
var e = {};
|
|
1476
|
-
|
|
1477
|
-
var
|
|
1623
|
+
T.exports = e;
|
|
1624
|
+
var o = f(0);
|
|
1478
1625
|
(function() {
|
|
1479
1626
|
e.create = function(a) {
|
|
1480
1627
|
var r = {};
|
|
1481
|
-
return a ||
|
|
1628
|
+
return a || o.log("Mouse.create: element was undefined, defaulting to document.body", "warn"), r.element = a || document.body, r.absolute = {
|
|
1482
1629
|
x: 0,
|
|
1483
1630
|
y: 0
|
|
1484
1631
|
}, r.position = {
|
|
@@ -1501,17 +1648,17 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1501
1648
|
mousedown: null,
|
|
1502
1649
|
mouseup: null,
|
|
1503
1650
|
mousewheel: null
|
|
1504
|
-
}, r.mousemove = function(
|
|
1505
|
-
var n = e._getRelativeMousePosition(
|
|
1506
|
-
|
|
1507
|
-
}, r.mousedown = function(
|
|
1508
|
-
var n = e._getRelativeMousePosition(
|
|
1509
|
-
|
|
1510
|
-
}, r.mouseup = function(
|
|
1511
|
-
var n = e._getRelativeMousePosition(
|
|
1512
|
-
|
|
1513
|
-
}, r.mousewheel = function(
|
|
1514
|
-
r.wheelDelta = Math.max(-1, Math.min(1,
|
|
1651
|
+
}, r.mousemove = function(c) {
|
|
1652
|
+
var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
|
|
1653
|
+
c.changedTouches && (r.button = 0, c.preventDefault()), r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.sourceEvents.mousemove = c;
|
|
1654
|
+
}, r.mousedown = function(c) {
|
|
1655
|
+
var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
|
|
1656
|
+
c.changedTouches ? (r.button = 0, c.preventDefault()) : r.button = c.button, r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.mousedownPosition.x = r.position.x, r.mousedownPosition.y = r.position.y, r.sourceEvents.mousedown = c;
|
|
1657
|
+
}, r.mouseup = function(c) {
|
|
1658
|
+
var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
|
|
1659
|
+
c.changedTouches && c.preventDefault(), r.button = -1, r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.mouseupPosition.x = r.position.x, r.mouseupPosition.y = r.position.y, r.sourceEvents.mouseup = c;
|
|
1660
|
+
}, r.mousewheel = function(c) {
|
|
1661
|
+
r.wheelDelta = Math.max(-1, Math.min(1, c.wheelDelta || -c.detail)), c.preventDefault(), r.sourceEvents.mousewheel = c;
|
|
1515
1662
|
}, e.setElement(r, r.element), r;
|
|
1516
1663
|
}, e.setElement = function(a, r) {
|
|
1517
1664
|
a.element = r, r.addEventListener("mousemove", a.mousemove, { passive: !0 }), r.addEventListener("mousedown", a.mousedown, { passive: !0 }), r.addEventListener("mouseup", a.mouseup, { passive: !0 }), r.addEventListener("wheel", a.mousewheel, { passive: !1 }), r.addEventListener("touchmove", a.mousemove, { passive: !1 }), r.addEventListener("touchstart", a.mousedown, { passive: !1 }), r.addEventListener("touchend", a.mouseup, { passive: !1 });
|
|
@@ -1521,24 +1668,24 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1521
1668
|
a.offset.x = r.x, a.offset.y = r.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y;
|
|
1522
1669
|
}, e.setScale = function(a, r) {
|
|
1523
1670
|
a.scale.x = r.x, a.scale.y = r.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y;
|
|
1524
|
-
}, e._getRelativeMousePosition = function(a, r,
|
|
1525
|
-
var n = r.getBoundingClientRect(),
|
|
1526
|
-
return i ? (s = i[0].pageX - n.left -
|
|
1527
|
-
x: s / (r.clientWidth / (r.width || r.clientWidth) *
|
|
1528
|
-
y:
|
|
1671
|
+
}, e._getRelativeMousePosition = function(a, r, c) {
|
|
1672
|
+
var n = r.getBoundingClientRect(), h = document.documentElement || document.body.parentNode || document.body, l = window.pageXOffset !== void 0 ? window.pageXOffset : h.scrollLeft, t = window.pageYOffset !== void 0 ? window.pageYOffset : h.scrollTop, i = a.changedTouches, s, u;
|
|
1673
|
+
return i ? (s = i[0].pageX - n.left - l, u = i[0].pageY - n.top - t) : (s = a.pageX - n.left - l, u = a.pageY - n.top - t), {
|
|
1674
|
+
x: s / (r.clientWidth / (r.width || r.clientWidth) * c),
|
|
1675
|
+
y: u / (r.clientHeight / (r.height || r.clientHeight) * c)
|
|
1529
1676
|
};
|
|
1530
1677
|
};
|
|
1531
1678
|
})();
|
|
1532
1679
|
}),
|
|
1533
|
-
(function(
|
|
1680
|
+
(function(T, A, f) {
|
|
1534
1681
|
var e = {};
|
|
1535
|
-
|
|
1536
|
-
var
|
|
1682
|
+
T.exports = e;
|
|
1683
|
+
var o = f(0);
|
|
1537
1684
|
(function() {
|
|
1538
1685
|
e._registry = {}, e.register = function(a) {
|
|
1539
|
-
if (e.isPlugin(a) ||
|
|
1540
|
-
var r = e._registry[a.name],
|
|
1541
|
-
|
|
1686
|
+
if (e.isPlugin(a) || o.warn("Plugin.register:", e.toString(a), "does not implement all required fields."), a.name in e._registry) {
|
|
1687
|
+
var r = e._registry[a.name], c = e.versionParse(a.version).number, n = e.versionParse(r.version).number;
|
|
1688
|
+
c > n ? (o.warn("Plugin.register:", e.toString(r), "was upgraded to", e.toString(a)), e._registry[a.name] = a) : c < n ? o.warn("Plugin.register:", e.toString(r), "can not be downgraded to", e.toString(a)) : a !== r && o.warn("Plugin.register:", e.toString(a), "is already registered to different plugin object");
|
|
1542
1689
|
} else e._registry[a.name] = a;
|
|
1543
1690
|
return a;
|
|
1544
1691
|
}, e.resolve = function(a) {
|
|
@@ -1550,36 +1697,36 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1550
1697
|
}, e.isUsed = function(a, r) {
|
|
1551
1698
|
return a.used.indexOf(r) > -1;
|
|
1552
1699
|
}, e.isFor = function(a, r) {
|
|
1553
|
-
var
|
|
1554
|
-
return !a.for || r.name ===
|
|
1700
|
+
var c = a.for && e.dependencyParse(a.for);
|
|
1701
|
+
return !a.for || r.name === c.name && e.versionSatisfies(r.version, c.range);
|
|
1555
1702
|
}, e.use = function(a, r) {
|
|
1556
1703
|
if (a.uses = (a.uses || []).concat(r || []), a.uses.length === 0) {
|
|
1557
|
-
|
|
1704
|
+
o.warn("Plugin.use:", e.toString(a), "does not specify any dependencies to install.");
|
|
1558
1705
|
return;
|
|
1559
1706
|
}
|
|
1560
|
-
for (var
|
|
1561
|
-
if (n[
|
|
1562
|
-
var t = e.resolve(n[
|
|
1707
|
+
for (var c = e.dependencies(a), n = o.topologicalSort(c), h = [], l = 0; l < n.length; l += 1)
|
|
1708
|
+
if (n[l] !== a.name) {
|
|
1709
|
+
var t = e.resolve(n[l]);
|
|
1563
1710
|
if (!t) {
|
|
1564
|
-
|
|
1711
|
+
h.push("❌ " + n[l]);
|
|
1565
1712
|
continue;
|
|
1566
1713
|
}
|
|
1567
|
-
e.isUsed(a, t.name) || (e.isFor(t, a) || (
|
|
1714
|
+
e.isUsed(a, t.name) || (e.isFor(t, a) || (o.warn("Plugin.use:", e.toString(t), "is for", t.for, "but installed on", e.toString(a) + "."), t._warned = !0), t.install ? t.install(a) : (o.warn("Plugin.use:", e.toString(t), "does not specify an install function."), t._warned = !0), t._warned ? (h.push("🔶 " + e.toString(t)), delete t._warned) : h.push("✅ " + e.toString(t)), a.used.push(t.name));
|
|
1568
1715
|
}
|
|
1569
|
-
|
|
1716
|
+
h.length > 0 && o.info(h.join(" "));
|
|
1570
1717
|
}, e.dependencies = function(a, r) {
|
|
1571
|
-
var
|
|
1718
|
+
var c = e.dependencyParse(a), n = c.name;
|
|
1572
1719
|
if (r = r || {}, !(n in r)) {
|
|
1573
|
-
a = e.resolve(a) || a, r[n] =
|
|
1574
|
-
e.isPlugin(
|
|
1575
|
-
var t = e.dependencyParse(
|
|
1576
|
-
return i && !e.versionSatisfies(i.version, t.range) ? (
|
|
1720
|
+
a = e.resolve(a) || a, r[n] = o.map(a.uses || [], function(l) {
|
|
1721
|
+
e.isPlugin(l) && e.register(l);
|
|
1722
|
+
var t = e.dependencyParse(l), i = e.resolve(l);
|
|
1723
|
+
return i && !e.versionSatisfies(i.version, t.range) ? (o.warn("Plugin.dependencies:", e.toString(i), "does not satisfy", e.toString(t), "used by", e.toString(c) + "."), i._warned = !0, a._warned = !0) : i || (o.warn("Plugin.dependencies:", e.toString(l), "used by", e.toString(c), "could not be resolved."), a._warned = !0), t.name;
|
|
1577
1724
|
});
|
|
1578
|
-
for (var
|
|
1725
|
+
for (var h = 0; h < r[n].length; h += 1) e.dependencies(r[n][h], r);
|
|
1579
1726
|
return r;
|
|
1580
1727
|
}
|
|
1581
1728
|
}, e.dependencyParse = function(a) {
|
|
1582
|
-
return
|
|
1729
|
+
return o.isString(a) ? (/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(a) || o.warn("Plugin.dependencyParse:", a, "is not a valid dependency string."), {
|
|
1583
1730
|
name: a.split("@")[0],
|
|
1584
1731
|
range: a.split("@")[1] || "*"
|
|
1585
1732
|
}) : {
|
|
@@ -1588,43 +1735,43 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1588
1735
|
};
|
|
1589
1736
|
}, e.versionParse = function(a) {
|
|
1590
1737
|
var r = /^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;
|
|
1591
|
-
r.test(a) ||
|
|
1592
|
-
var
|
|
1738
|
+
r.test(a) || o.warn("Plugin.versionParse:", a, "is not a valid version or range.");
|
|
1739
|
+
var c = r.exec(a), n = Number(c[4]), h = Number(c[5]), l = Number(c[6]);
|
|
1593
1740
|
return {
|
|
1594
|
-
isRange: !!(
|
|
1595
|
-
version:
|
|
1741
|
+
isRange: !!(c[1] || c[2]),
|
|
1742
|
+
version: c[3],
|
|
1596
1743
|
range: a,
|
|
1597
|
-
operator:
|
|
1744
|
+
operator: c[1] || c[2] || "",
|
|
1598
1745
|
major: n,
|
|
1599
|
-
minor:
|
|
1600
|
-
patch:
|
|
1746
|
+
minor: h,
|
|
1747
|
+
patch: l,
|
|
1601
1748
|
parts: [
|
|
1602
1749
|
n,
|
|
1603
|
-
|
|
1604
|
-
|
|
1750
|
+
h,
|
|
1751
|
+
l
|
|
1605
1752
|
],
|
|
1606
|
-
prerelease:
|
|
1607
|
-
number: n * 1e8 +
|
|
1753
|
+
prerelease: c[7],
|
|
1754
|
+
number: n * 1e8 + h * 1e4 + l
|
|
1608
1755
|
};
|
|
1609
1756
|
}, e.versionSatisfies = function(a, r) {
|
|
1610
1757
|
r = r || "*";
|
|
1611
|
-
var
|
|
1612
|
-
if (
|
|
1613
|
-
if (
|
|
1614
|
-
if (
|
|
1615
|
-
if (
|
|
1616
|
-
if (
|
|
1617
|
-
if (
|
|
1618
|
-
return
|
|
1758
|
+
var c = e.versionParse(r), n = e.versionParse(a);
|
|
1759
|
+
if (c.isRange) {
|
|
1760
|
+
if (c.operator === "*" || a === "*") return !0;
|
|
1761
|
+
if (c.operator === ">") return n.number > c.number;
|
|
1762
|
+
if (c.operator === ">=") return n.number >= c.number;
|
|
1763
|
+
if (c.operator === "~") return n.major === c.major && n.minor === c.minor && n.patch >= c.patch;
|
|
1764
|
+
if (c.operator === "^")
|
|
1765
|
+
return c.major > 0 ? n.major === c.major && n.number >= c.number : c.minor > 0 ? n.minor === c.minor && n.patch >= c.patch : n.patch === c.patch;
|
|
1619
1766
|
}
|
|
1620
1767
|
return a === r || a === "*";
|
|
1621
1768
|
};
|
|
1622
1769
|
})();
|
|
1623
1770
|
}),
|
|
1624
|
-
(function(
|
|
1625
|
-
var
|
|
1626
|
-
|
|
1627
|
-
|
|
1771
|
+
(function(T, A) {
|
|
1772
|
+
var f = {};
|
|
1773
|
+
T.exports = f, (function() {
|
|
1774
|
+
f.create = function(e) {
|
|
1628
1775
|
return {
|
|
1629
1776
|
vertex: e,
|
|
1630
1777
|
normalImpulse: 0,
|
|
@@ -1633,14 +1780,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1633
1780
|
};
|
|
1634
1781
|
})();
|
|
1635
1782
|
}),
|
|
1636
|
-
(function(
|
|
1783
|
+
(function(T, A, f) {
|
|
1637
1784
|
var e = {};
|
|
1638
|
-
|
|
1639
|
-
var
|
|
1785
|
+
T.exports = e;
|
|
1786
|
+
var o = f(7), a = f(18), r = f(13), c = f(19), n = f(5), h = f(6), l = f(10), t = f(0), i = f(4);
|
|
1640
1787
|
(function() {
|
|
1641
1788
|
e._deltaMax = 1e3 / 60, e.create = function(s) {
|
|
1642
1789
|
s = s || {};
|
|
1643
|
-
var
|
|
1790
|
+
var u = t.extend({
|
|
1644
1791
|
positionIterations: 6,
|
|
1645
1792
|
velocityIterations: 4,
|
|
1646
1793
|
constraintIterations: 2,
|
|
@@ -1660,144 +1807,144 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1660
1807
|
lastUpdatesPerFrame: 0
|
|
1661
1808
|
}
|
|
1662
1809
|
}, s);
|
|
1663
|
-
return
|
|
1664
|
-
}, e.update = function(s,
|
|
1665
|
-
var m = t.now(), x = s.world, P = s.detector,
|
|
1666
|
-
|
|
1810
|
+
return u.world = s.world || h.create({ label: "World" }), u.pairs = s.pairs || c.create(), u.detector = s.detector || r.create(), u.detector.pairs = u.pairs, u.grid = { buckets: [] }, u.world.gravity = u.gravity, u.broadphase = u.grid, u.metrics = {}, u;
|
|
1811
|
+
}, e.update = function(s, u) {
|
|
1812
|
+
var m = t.now(), x = s.world, P = s.detector, B = s.pairs, g = s.timing, p = g.timestamp, y;
|
|
1813
|
+
u > e._deltaMax && t.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to", e._deltaMax.toFixed(3), "ms."), u = typeof u < "u" ? u : t._baseDelta, u *= g.timeScale, g.timestamp += u, g.lastDelta = u;
|
|
1667
1814
|
var v = {
|
|
1668
1815
|
timestamp: g.timestamp,
|
|
1669
|
-
delta:
|
|
1816
|
+
delta: u
|
|
1670
1817
|
};
|
|
1671
1818
|
n.trigger(s, "beforeUpdate", v);
|
|
1672
|
-
var w =
|
|
1673
|
-
for (x.isModified && (r.setBodies(P, w),
|
|
1674
|
-
|
|
1819
|
+
var w = h.allBodies(x), S = h.allConstraints(x);
|
|
1820
|
+
for (x.isModified && (r.setBodies(P, w), h.setModified(x, !1, !1, !0)), s.enableSleeping && o.update(w, u), e._bodiesApplyGravity(w, s.gravity), u > 0 && e._bodiesUpdate(w, u), n.trigger(s, "beforeSolve", v), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, u);
|
|
1821
|
+
l.postSolveAll(w);
|
|
1675
1822
|
var C = r.collisions(P);
|
|
1676
|
-
|
|
1677
|
-
pairs:
|
|
1823
|
+
c.update(B, C, p), s.enableSleeping && o.afterCollisions(B.list), B.collisionStart.length > 0 && n.trigger(s, "collisionStart", {
|
|
1824
|
+
pairs: B.collisionStart,
|
|
1678
1825
|
timestamp: g.timestamp,
|
|
1679
|
-
delta:
|
|
1826
|
+
delta: u
|
|
1680
1827
|
});
|
|
1681
1828
|
var M = t.clamp(20 / s.positionIterations, 0, 1);
|
|
1682
|
-
for (a.preSolvePosition(
|
|
1683
|
-
for (a.postSolvePosition(w),
|
|
1684
|
-
for (
|
|
1685
|
-
return e._bodiesUpdateVelocities(w),
|
|
1686
|
-
pairs:
|
|
1829
|
+
for (a.preSolvePosition(B.list), y = 0; y < s.positionIterations; y++) a.solvePosition(B.list, u, M);
|
|
1830
|
+
for (a.postSolvePosition(w), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, u);
|
|
1831
|
+
for (l.postSolveAll(w), a.preSolveVelocity(B.list), y = 0; y < s.velocityIterations; y++) a.solveVelocity(B.list, u);
|
|
1832
|
+
return e._bodiesUpdateVelocities(w), B.collisionActive.length > 0 && n.trigger(s, "collisionActive", {
|
|
1833
|
+
pairs: B.collisionActive,
|
|
1687
1834
|
timestamp: g.timestamp,
|
|
1688
|
-
delta:
|
|
1689
|
-
}),
|
|
1690
|
-
pairs:
|
|
1835
|
+
delta: u
|
|
1836
|
+
}), B.collisionEnd.length > 0 && n.trigger(s, "collisionEnd", {
|
|
1837
|
+
pairs: B.collisionEnd,
|
|
1691
1838
|
timestamp: g.timestamp,
|
|
1692
|
-
delta:
|
|
1839
|
+
delta: u
|
|
1693
1840
|
}), e._bodiesClearForces(w), n.trigger(s, "afterUpdate", v), s.timing.lastElapsed = t.now() - m, s;
|
|
1694
|
-
}, e.merge = function(s,
|
|
1695
|
-
if (t.extend(s,
|
|
1696
|
-
s.world =
|
|
1697
|
-
for (var m =
|
|
1841
|
+
}, e.merge = function(s, u) {
|
|
1842
|
+
if (t.extend(s, u), u.world) {
|
|
1843
|
+
s.world = u.world, e.clear(s);
|
|
1844
|
+
for (var m = h.allBodies(s.world), x = 0; x < m.length; x++) {
|
|
1698
1845
|
var P = m[x];
|
|
1699
|
-
|
|
1846
|
+
o.set(P, !1), P.id = t.nextId();
|
|
1700
1847
|
}
|
|
1701
1848
|
}
|
|
1702
1849
|
}, e.clear = function(s) {
|
|
1703
|
-
|
|
1850
|
+
c.clear(s.pairs), r.clear(s.detector);
|
|
1704
1851
|
}, e._bodiesClearForces = function(s) {
|
|
1705
|
-
for (var
|
|
1852
|
+
for (var u = s.length, m = 0; m < u; m++) {
|
|
1706
1853
|
var x = s[m];
|
|
1707
1854
|
x.force.x = 0, x.force.y = 0, x.torque = 0;
|
|
1708
1855
|
}
|
|
1709
|
-
}, e._bodiesApplyGravity = function(s,
|
|
1710
|
-
var m = typeof
|
|
1711
|
-
if (!(
|
|
1856
|
+
}, e._bodiesApplyGravity = function(s, u) {
|
|
1857
|
+
var m = typeof u.scale < "u" ? u.scale : 1e-3, x = s.length;
|
|
1858
|
+
if (!(u.x === 0 && u.y === 0 || m === 0))
|
|
1712
1859
|
for (var P = 0; P < x; P++) {
|
|
1713
|
-
var
|
|
1714
|
-
|
|
1860
|
+
var B = s[P];
|
|
1861
|
+
B.isStatic || B.isSleeping || (B.force.y += B.mass * u.y * m, B.force.x += B.mass * u.x * m);
|
|
1715
1862
|
}
|
|
1716
|
-
}, e._bodiesUpdate = function(s,
|
|
1863
|
+
}, e._bodiesUpdate = function(s, u) {
|
|
1717
1864
|
for (var m = s.length, x = 0; x < m; x++) {
|
|
1718
1865
|
var P = s[x];
|
|
1719
|
-
P.isStatic || P.isSleeping || i.update(P,
|
|
1866
|
+
P.isStatic || P.isSleeping || i.update(P, u);
|
|
1720
1867
|
}
|
|
1721
1868
|
}, e._bodiesUpdateVelocities = function(s) {
|
|
1722
|
-
for (var
|
|
1869
|
+
for (var u = s.length, m = 0; m < u; m++) i.updateVelocities(s[m]);
|
|
1723
1870
|
};
|
|
1724
1871
|
})();
|
|
1725
1872
|
}),
|
|
1726
|
-
(function(
|
|
1873
|
+
(function(T, A, f) {
|
|
1727
1874
|
var e = {};
|
|
1728
|
-
|
|
1729
|
-
var
|
|
1875
|
+
T.exports = e;
|
|
1876
|
+
var o = f(3), a = f(0), r = f(1);
|
|
1730
1877
|
(function() {
|
|
1731
|
-
e._restingThresh = 2, e._restingThreshTangent = Math.sqrt(6), e._positionDampen = 0.9, e._positionWarming = 0.8, e._frictionNormalMultiplier = 5, e._frictionMaxStatic = Number.MAX_VALUE, e.preSolvePosition = function(
|
|
1732
|
-
var n,
|
|
1878
|
+
e._restingThresh = 2, e._restingThreshTangent = Math.sqrt(6), e._positionDampen = 0.9, e._positionWarming = 0.8, e._frictionNormalMultiplier = 5, e._frictionMaxStatic = Number.MAX_VALUE, e.preSolvePosition = function(c) {
|
|
1879
|
+
var n, h, l, t = c.length;
|
|
1733
1880
|
for (n = 0; n < t; n++)
|
|
1734
|
-
|
|
1735
|
-
}, e.solvePosition = function(
|
|
1736
|
-
var
|
|
1737
|
-
for (
|
|
1738
|
-
t =
|
|
1739
|
-
for (
|
|
1740
|
-
t =
|
|
1741
|
-
}, e.postSolvePosition = function(
|
|
1742
|
-
for (var n = e._positionWarming,
|
|
1743
|
-
var s =
|
|
1881
|
+
h = c[n], h.isActive && (l = h.contactCount, h.collision.parentA.totalContacts += l, h.collision.parentB.totalContacts += l);
|
|
1882
|
+
}, e.solvePosition = function(c, n, h) {
|
|
1883
|
+
var l, t, i, s, u, m, x, P, B = e._positionDampen * (h || 1), g = a.clamp(n / a._baseDelta, 0, 1), p = c.length;
|
|
1884
|
+
for (l = 0; l < p; l++)
|
|
1885
|
+
t = c[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, u = i.parentB, m = i.normal, t.separation = i.depth + m.x * (u.positionImpulse.x - s.positionImpulse.x) + m.y * (u.positionImpulse.y - s.positionImpulse.y));
|
|
1886
|
+
for (l = 0; l < p; l++)
|
|
1887
|
+
t = c[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, u = i.parentB, m = i.normal, P = t.separation - t.slop * g, (s.isStatic || u.isStatic) && (P *= 2), s.isStatic || s.isSleeping || (x = B / s.totalContacts, s.positionImpulse.x += m.x * P * x, s.positionImpulse.y += m.y * P * x), u.isStatic || u.isSleeping || (x = B / u.totalContacts, u.positionImpulse.x -= m.x * P * x, u.positionImpulse.y -= m.y * P * x));
|
|
1888
|
+
}, e.postSolvePosition = function(c) {
|
|
1889
|
+
for (var n = e._positionWarming, h = c.length, l = o.translate, t = r.update, i = 0; i < h; i++) {
|
|
1890
|
+
var s = c[i], u = s.positionImpulse, m = u.x, x = u.y, P = s.velocity;
|
|
1744
1891
|
if (s.totalContacts = 0, m !== 0 || x !== 0) {
|
|
1745
|
-
for (var
|
|
1746
|
-
var g = s.parts[
|
|
1747
|
-
|
|
1892
|
+
for (var B = 0; B < s.parts.length; B++) {
|
|
1893
|
+
var g = s.parts[B];
|
|
1894
|
+
l(g.vertices, u), t(g.bounds, g.vertices, P), g.position.x += m, g.position.y += x;
|
|
1748
1895
|
}
|
|
1749
|
-
s.positionPrev.x += m, s.positionPrev.y += x, m * P.x + x * P.y < 0 ? (
|
|
1896
|
+
s.positionPrev.x += m, s.positionPrev.y += x, m * P.x + x * P.y < 0 ? (u.x = 0, u.y = 0) : (u.x *= n, u.y *= n);
|
|
1750
1897
|
}
|
|
1751
1898
|
}
|
|
1752
|
-
}, e.preSolveVelocity = function(
|
|
1753
|
-
var n =
|
|
1754
|
-
for (
|
|
1755
|
-
var t = h
|
|
1899
|
+
}, e.preSolveVelocity = function(c) {
|
|
1900
|
+
var n = c.length, h, l;
|
|
1901
|
+
for (h = 0; h < n; h++) {
|
|
1902
|
+
var t = c[h];
|
|
1756
1903
|
if (!(!t.isActive || t.isSensor)) {
|
|
1757
|
-
var i = t.contacts, s = t.contactCount,
|
|
1758
|
-
for (
|
|
1759
|
-
var g = i[
|
|
1904
|
+
var i = t.contacts, s = t.contactCount, u = t.collision, m = u.parentA, x = u.parentB, P = u.normal, B = u.tangent;
|
|
1905
|
+
for (l = 0; l < s; l++) {
|
|
1906
|
+
var g = i[l], p = g.vertex, y = g.normalImpulse, v = g.tangentImpulse;
|
|
1760
1907
|
if (y !== 0 || v !== 0) {
|
|
1761
|
-
var w = P.x * y +
|
|
1908
|
+
var w = P.x * y + B.x * v, S = P.y * y + B.y * v;
|
|
1762
1909
|
m.isStatic || m.isSleeping || (m.positionPrev.x += w * m.inverseMass, m.positionPrev.y += S * m.inverseMass, m.anglePrev += m.inverseInertia * ((p.x - m.position.x) * S - (p.y - m.position.y) * w)), x.isStatic || x.isSleeping || (x.positionPrev.x -= w * x.inverseMass, x.positionPrev.y -= S * x.inverseMass, x.anglePrev -= x.inverseInertia * ((p.x - x.position.x) * S - (p.y - x.position.y) * w));
|
|
1763
1910
|
}
|
|
1764
1911
|
}
|
|
1765
1912
|
}
|
|
1766
1913
|
}
|
|
1767
|
-
}, e.solveVelocity = function(
|
|
1768
|
-
var
|
|
1769
|
-
for (
|
|
1770
|
-
var p =
|
|
1914
|
+
}, e.solveVelocity = function(c, n) {
|
|
1915
|
+
var h = n / a._baseDelta, l = h * h * h, t = -e._restingThresh * h, i = e._restingThreshTangent, s = e._frictionNormalMultiplier * h, u = e._frictionMaxStatic, m = c.length, x, P, B, g;
|
|
1916
|
+
for (B = 0; B < m; B++) {
|
|
1917
|
+
var p = c[B];
|
|
1771
1918
|
if (!(!p.isActive || p.isSensor)) {
|
|
1772
|
-
var y = p.collision, v = y.parentA, w = y.parentB, S = y.normal.x, C = y.normal.y, M = y.tangent.x, I = y.tangent.y, R = p.inverseMass, L = p.friction * p.frictionStatic * s,
|
|
1919
|
+
var y = p.collision, v = y.parentA, w = y.parentB, S = y.normal.x, C = y.normal.y, M = y.tangent.x, I = y.tangent.y, R = p.inverseMass, L = p.friction * p.frictionStatic * s, b = p.contacts, k = p.contactCount, D = 1 / k, F = v.position.x - v.positionPrev.x, H = v.position.y - v.positionPrev.y, G = v.angle - v.anglePrev, V = w.position.x - w.positionPrev.x, Q = w.position.y - w.positionPrev.y, X = w.angle - w.anglePrev;
|
|
1773
1920
|
for (g = 0; g < k; g++) {
|
|
1774
|
-
var
|
|
1775
|
-
|
|
1776
|
-
var
|
|
1777
|
-
$ < -
|
|
1778
|
-
var
|
|
1779
|
-
if (x *= ve,
|
|
1921
|
+
var U = b[g], W = U.vertex, N = W.x - v.position.x, J = W.y - v.position.y, K = W.x - w.position.x, Y = W.y - w.position.y, z = F - J * G, we = H + N * G, Pe = V - Y * X, Ce = Q + K * X, ue = z - Pe, fe = we - Ce, se = S * ue + C * fe, $ = M * ue + I * fe, ce = p.separation + se, re = Math.min(ce, 1);
|
|
1922
|
+
re = ce < 0 ? 0 : re;
|
|
1923
|
+
var he = re * L;
|
|
1924
|
+
$ < -he || $ > he ? (P = $ > 0 ? $ : -$, x = p.friction * ($ > 0 ? 1 : -1) * l, x < -P ? x = -P : x > P && (x = P)) : (x = $, P = u);
|
|
1925
|
+
var ge = N * C - J * S, de = K * C - Y * S, ve = D / (R + v.inverseInertia * ge * ge + w.inverseInertia * de * de), j = (1 + p.restitution) * se * ve;
|
|
1926
|
+
if (x *= ve, se < t) U.normalImpulse = 0;
|
|
1780
1927
|
else {
|
|
1781
|
-
var
|
|
1782
|
-
|
|
1928
|
+
var Me = U.normalImpulse;
|
|
1929
|
+
U.normalImpulse += j, U.normalImpulse > 0 && (U.normalImpulse = 0), j = U.normalImpulse - Me;
|
|
1783
1930
|
}
|
|
1784
|
-
if ($ < -i || $ > i)
|
|
1931
|
+
if ($ < -i || $ > i) U.tangentImpulse = 0;
|
|
1785
1932
|
else {
|
|
1786
|
-
var
|
|
1787
|
-
|
|
1933
|
+
var Te = U.tangentImpulse;
|
|
1934
|
+
U.tangentImpulse += x, U.tangentImpulse < -P && (U.tangentImpulse = -P), U.tangentImpulse > P && (U.tangentImpulse = P), x = U.tangentImpulse - Te;
|
|
1788
1935
|
}
|
|
1789
1936
|
var q = S * j + M * x, _ = C * j + I * x;
|
|
1790
|
-
v.isStatic || v.isSleeping || (v.positionPrev.x += q * v.inverseMass, v.positionPrev.y += _ * v.inverseMass, v.anglePrev += (
|
|
1937
|
+
v.isStatic || v.isSleeping || (v.positionPrev.x += q * v.inverseMass, v.positionPrev.y += _ * v.inverseMass, v.anglePrev += (N * _ - J * q) * v.inverseInertia), w.isStatic || w.isSleeping || (w.positionPrev.x -= q * w.inverseMass, w.positionPrev.y -= _ * w.inverseMass, w.anglePrev -= (K * _ - Y * q) * w.inverseInertia);
|
|
1791
1938
|
}
|
|
1792
1939
|
}
|
|
1793
1940
|
}
|
|
1794
1941
|
};
|
|
1795
1942
|
})();
|
|
1796
1943
|
}),
|
|
1797
|
-
(function(
|
|
1944
|
+
(function(T, A, f) {
|
|
1798
1945
|
var e = {};
|
|
1799
|
-
|
|
1800
|
-
var
|
|
1946
|
+
T.exports = e;
|
|
1947
|
+
var o = f(9), a = f(0);
|
|
1801
1948
|
(function() {
|
|
1802
1949
|
e.create = function(r) {
|
|
1803
1950
|
return a.extend({
|
|
@@ -1807,60 +1954,60 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1807
1954
|
collisionActive: [],
|
|
1808
1955
|
collisionEnd: []
|
|
1809
1956
|
}, r);
|
|
1810
|
-
}, e.update = function(r,
|
|
1811
|
-
var
|
|
1957
|
+
}, e.update = function(r, c, n) {
|
|
1958
|
+
var h = o.update, l = o.create, t = o.setActive, i = r.table, s = r.list, u = s.length, m = u, x = r.collisionStart, P = r.collisionEnd, B = r.collisionActive, g = c.length, p = 0, y = 0, v = 0, w, S, C;
|
|
1812
1959
|
for (C = 0; C < g; C++)
|
|
1813
|
-
w =
|
|
1814
|
-
for (m = 0,
|
|
1960
|
+
w = c[C], S = w.pair, S ? (S.isActive && (B[v++] = S), h(S, w, n)) : (S = l(w, n), i[S.id] = S, x[p++] = S, s[m++] = S);
|
|
1961
|
+
for (m = 0, u = s.length, C = 0; C < u; C++)
|
|
1815
1962
|
S = s[C], S.timeUpdated >= n ? s[m++] = S : (t(S, !1, n), S.collision.bodyA.sleepCounter > 0 && S.collision.bodyB.sleepCounter > 0 ? s[m++] = S : (P[y++] = S, delete i[S.id]));
|
|
1816
|
-
s.length !== m && (s.length = m), x.length !== p && (x.length = p), P.length !== y && (P.length = y),
|
|
1963
|
+
s.length !== m && (s.length = m), x.length !== p && (x.length = p), P.length !== y && (P.length = y), B.length !== v && (B.length = v);
|
|
1817
1964
|
}, e.clear = function(r) {
|
|
1818
1965
|
return r.table = {}, r.list.length = 0, r.collisionStart.length = 0, r.collisionActive.length = 0, r.collisionEnd.length = 0, r;
|
|
1819
1966
|
};
|
|
1820
1967
|
})();
|
|
1821
1968
|
}),
|
|
1822
|
-
(function(
|
|
1823
|
-
var e =
|
|
1824
|
-
e.Axes =
|
|
1969
|
+
(function(T, A, f) {
|
|
1970
|
+
var e = T.exports = f(21);
|
|
1971
|
+
e.Axes = f(11), e.Bodies = f(12), e.Body = f(4), e.Bounds = f(1), e.Collision = f(8), e.Common = f(0), e.Composite = f(6), e.Composites = f(22), e.Constraint = f(10), e.Contact = f(16), e.Detector = f(13), e.Engine = f(17), e.Events = f(5), e.Grid = f(23), e.Mouse = f(14), e.MouseConstraint = f(24), e.Pair = f(9), e.Pairs = f(19), e.Plugin = f(15), e.Query = f(25), e.Render = f(26), e.Resolver = f(18), e.Runner = f(27), e.SAT = f(28), e.Sleeping = f(7), e.Svg = f(29), e.Vector = f(2), e.Vertices = f(3), e.World = f(30), e.Engine.run = e.Runner.run, e.Common.deprecated(e.Engine, "run", "Engine.run ➤ use Matter.Runner.run(engine) instead");
|
|
1825
1972
|
}),
|
|
1826
|
-
(function(
|
|
1973
|
+
(function(T, A, f) {
|
|
1827
1974
|
var e = {};
|
|
1828
|
-
|
|
1829
|
-
var
|
|
1975
|
+
T.exports = e;
|
|
1976
|
+
var o = f(15), a = f(0);
|
|
1830
1977
|
(function() {
|
|
1831
1978
|
e.name = "matter-js", e.version = "0.20.0", e.uses = [], e.used = [], e.use = function() {
|
|
1832
|
-
|
|
1833
|
-
}, e.before = function(r,
|
|
1834
|
-
return r = r.replace(/^Matter./, ""), a.chainPathBefore(e, r,
|
|
1835
|
-
}, e.after = function(r,
|
|
1836
|
-
return r = r.replace(/^Matter./, ""), a.chainPathAfter(e, r,
|
|
1979
|
+
o.use(e, Array.prototype.slice.call(arguments));
|
|
1980
|
+
}, e.before = function(r, c) {
|
|
1981
|
+
return r = r.replace(/^Matter./, ""), a.chainPathBefore(e, r, c);
|
|
1982
|
+
}, e.after = function(r, c) {
|
|
1983
|
+
return r = r.replace(/^Matter./, ""), a.chainPathAfter(e, r, c);
|
|
1837
1984
|
};
|
|
1838
1985
|
})();
|
|
1839
1986
|
}),
|
|
1840
|
-
(function(
|
|
1987
|
+
(function(T, A, f) {
|
|
1841
1988
|
var e = {};
|
|
1842
|
-
|
|
1843
|
-
var
|
|
1989
|
+
T.exports = e;
|
|
1990
|
+
var o = f(6), a = f(10), r = f(0), c = f(4), n = f(12), h = r.deprecated;
|
|
1844
1991
|
(function() {
|
|
1845
|
-
e.stack = function(
|
|
1846
|
-
for (var P =
|
|
1992
|
+
e.stack = function(l, t, i, s, u, m, x) {
|
|
1993
|
+
for (var P = o.create({ label: "Stack" }), B = l, g = t, p, y = 0, v = 0; v < s; v++) {
|
|
1847
1994
|
for (var w = 0, S = 0; S < i; S++) {
|
|
1848
|
-
var C = x(
|
|
1995
|
+
var C = x(B, g, S, v, p, y);
|
|
1849
1996
|
if (C) {
|
|
1850
1997
|
var M = C.bounds.max.y - C.bounds.min.y, I = C.bounds.max.x - C.bounds.min.x;
|
|
1851
|
-
M > w && (w = M),
|
|
1998
|
+
M > w && (w = M), c.translate(C, {
|
|
1852
1999
|
x: I * 0.5,
|
|
1853
2000
|
y: M * 0.5
|
|
1854
|
-
}),
|
|
1855
|
-
} else
|
|
2001
|
+
}), B = C.bounds.max.x + u, o.addBody(P, C), p = C, y += 1;
|
|
2002
|
+
} else B += u;
|
|
1856
2003
|
}
|
|
1857
|
-
g += w + m,
|
|
2004
|
+
g += w + m, B = l;
|
|
1858
2005
|
}
|
|
1859
2006
|
return P;
|
|
1860
|
-
}, e.chain = function(
|
|
1861
|
-
for (var x =
|
|
1862
|
-
var
|
|
1863
|
-
bodyA:
|
|
2007
|
+
}, e.chain = function(l, t, i, s, u, m) {
|
|
2008
|
+
for (var x = l.bodies, P = 1; P < x.length; P++) {
|
|
2009
|
+
var B = x[P - 1], g = x[P], p = B.bounds.max.y - B.bounds.min.y, y = B.bounds.max.x - B.bounds.min.x, v = g.bounds.max.y - g.bounds.min.y, w = g.bounds.max.x - g.bounds.min.x, S = {
|
|
2010
|
+
bodyA: B,
|
|
1864
2011
|
pointA: {
|
|
1865
2012
|
x: y * t,
|
|
1866
2013
|
y: p * i
|
|
@@ -1868,49 +2015,49 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1868
2015
|
bodyB: g,
|
|
1869
2016
|
pointB: {
|
|
1870
2017
|
x: w * s,
|
|
1871
|
-
y: v *
|
|
2018
|
+
y: v * u
|
|
1872
2019
|
}
|
|
1873
2020
|
}, C = r.extend(S, m);
|
|
1874
|
-
|
|
2021
|
+
o.addConstraint(l, a.create(C));
|
|
1875
2022
|
}
|
|
1876
|
-
return
|
|
1877
|
-
}, e.mesh = function(
|
|
1878
|
-
var m =
|
|
2023
|
+
return l.label += " Chain", l;
|
|
2024
|
+
}, e.mesh = function(l, t, i, s, u) {
|
|
2025
|
+
var m = l.bodies, x, P, B, g, p;
|
|
1879
2026
|
for (x = 0; x < i; x++) {
|
|
1880
2027
|
for (P = 1; P < t; P++)
|
|
1881
|
-
|
|
1882
|
-
bodyA:
|
|
2028
|
+
B = m[P - 1 + x * t], g = m[P + x * t], o.addConstraint(l, a.create(r.extend({
|
|
2029
|
+
bodyA: B,
|
|
1883
2030
|
bodyB: g
|
|
1884
|
-
},
|
|
2031
|
+
}, u)));
|
|
1885
2032
|
if (x > 0) for (P = 0; P < t; P++)
|
|
1886
|
-
|
|
1887
|
-
bodyA:
|
|
2033
|
+
B = m[P + (x - 1) * t], g = m[P + x * t], o.addConstraint(l, a.create(r.extend({
|
|
2034
|
+
bodyA: B,
|
|
1888
2035
|
bodyB: g
|
|
1889
|
-
},
|
|
2036
|
+
}, u))), s && P > 0 && (p = m[P - 1 + (x - 1) * t], o.addConstraint(l, a.create(r.extend({
|
|
1890
2037
|
bodyA: p,
|
|
1891
2038
|
bodyB: g
|
|
1892
|
-
},
|
|
2039
|
+
}, u)))), s && P < t - 1 && (p = m[P + 1 + (x - 1) * t], o.addConstraint(l, a.create(r.extend({
|
|
1893
2040
|
bodyA: p,
|
|
1894
2041
|
bodyB: g
|
|
1895
|
-
},
|
|
2042
|
+
}, u))));
|
|
1896
2043
|
}
|
|
1897
|
-
return
|
|
1898
|
-
}, e.pyramid = function(
|
|
1899
|
-
return e.stack(
|
|
2044
|
+
return l.label += " Mesh", l;
|
|
2045
|
+
}, e.pyramid = function(l, t, i, s, u, m, x) {
|
|
2046
|
+
return e.stack(l, t, i, s, u, m, function(P, B, g, p, y, v) {
|
|
1900
2047
|
var w = Math.min(s, Math.ceil(i / 2)), S = y ? y.bounds.max.x - y.bounds.min.x : 0;
|
|
1901
2048
|
if (!(p > w)) {
|
|
1902
2049
|
p = w - p;
|
|
1903
2050
|
var C = p, M = i - 1 - p;
|
|
1904
2051
|
if (!(g < C || g > M))
|
|
1905
|
-
return v === 1 &&
|
|
2052
|
+
return v === 1 && c.translate(y, {
|
|
1906
2053
|
x: (g + (i % 2 === 1 ? 1 : -1)) * S,
|
|
1907
2054
|
y: 0
|
|
1908
|
-
}), x(
|
|
2055
|
+
}), x(l + (y ? g * S : 0) + g * u, B, g, p, y, v);
|
|
1909
2056
|
}
|
|
1910
2057
|
});
|
|
1911
|
-
}, e.newtonsCradle = function(
|
|
1912
|
-
for (var m =
|
|
1913
|
-
var P = 1.9,
|
|
2058
|
+
}, e.newtonsCradle = function(l, t, i, s, u) {
|
|
2059
|
+
for (var m = o.create({ label: "Newtons Cradle" }), x = 0; x < i; x++) {
|
|
2060
|
+
var P = 1.9, B = n.circle(l + x * (s * P), t + u, s, {
|
|
1914
2061
|
inertia: 1 / 0,
|
|
1915
2062
|
restitution: 1,
|
|
1916
2063
|
friction: 0,
|
|
@@ -1918,23 +2065,23 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1918
2065
|
slop: 1
|
|
1919
2066
|
}), g = a.create({
|
|
1920
2067
|
pointA: {
|
|
1921
|
-
x:
|
|
2068
|
+
x: l + x * (s * P),
|
|
1922
2069
|
y: t
|
|
1923
2070
|
},
|
|
1924
|
-
bodyB:
|
|
2071
|
+
bodyB: B
|
|
1925
2072
|
});
|
|
1926
|
-
|
|
2073
|
+
o.addBody(m, B), o.addConstraint(m, g);
|
|
1927
2074
|
}
|
|
1928
2075
|
return m;
|
|
1929
|
-
},
|
|
1930
|
-
var m =
|
|
2076
|
+
}, h(e, "newtonsCradle", "Composites.newtonsCradle ➤ moved to newtonsCradle example"), e.car = function(l, t, i, s, u) {
|
|
2077
|
+
var m = c.nextGroup(!0), x = 20, P = -i * 0.5 + x, B = i * 0.5 - x, g = 0, p = o.create({ label: "Car" }), y = n.rectangle(l, t, i, s, {
|
|
1931
2078
|
collisionFilter: { group: m },
|
|
1932
2079
|
chamfer: { radius: s * 0.5 },
|
|
1933
2080
|
density: 2e-4
|
|
1934
|
-
}), v = n.circle(
|
|
2081
|
+
}), v = n.circle(l + P, t + g, u, {
|
|
1935
2082
|
collisionFilter: { group: m },
|
|
1936
2083
|
friction: 0.8
|
|
1937
|
-
}), w = n.circle(
|
|
2084
|
+
}), w = n.circle(l + B, t + g, u, {
|
|
1938
2085
|
collisionFilter: { group: m },
|
|
1939
2086
|
friction: 0.8
|
|
1940
2087
|
}), S = a.create({
|
|
@@ -1949,120 +2096,120 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
1949
2096
|
}), C = a.create({
|
|
1950
2097
|
bodyB: y,
|
|
1951
2098
|
pointB: {
|
|
1952
|
-
x:
|
|
2099
|
+
x: B,
|
|
1953
2100
|
y: g
|
|
1954
2101
|
},
|
|
1955
2102
|
bodyA: w,
|
|
1956
2103
|
stiffness: 1,
|
|
1957
2104
|
length: 0
|
|
1958
2105
|
});
|
|
1959
|
-
return
|
|
1960
|
-
},
|
|
1961
|
-
|
|
2106
|
+
return o.addBody(p, y), o.addBody(p, v), o.addBody(p, w), o.addConstraint(p, S), o.addConstraint(p, C), p;
|
|
2107
|
+
}, h(e, "car", "Composites.car ➤ moved to car example"), e.softBody = function(l, t, i, s, u, m, x, P, B, g) {
|
|
2108
|
+
B = r.extend({ inertia: 1 / 0 }, B), g = r.extend({
|
|
1962
2109
|
stiffness: 0.2,
|
|
1963
2110
|
render: {
|
|
1964
2111
|
type: "line",
|
|
1965
2112
|
anchors: !1
|
|
1966
2113
|
}
|
|
1967
2114
|
}, g);
|
|
1968
|
-
var p = e.stack(
|
|
1969
|
-
return n.circle(y, v, P,
|
|
2115
|
+
var p = e.stack(l, t, i, s, u, m, function(y, v) {
|
|
2116
|
+
return n.circle(y, v, P, B);
|
|
1970
2117
|
});
|
|
1971
2118
|
return e.mesh(p, i, s, x, g), p.label = "Soft Body", p;
|
|
1972
|
-
},
|
|
2119
|
+
}, h(e, "softBody", "Composites.softBody ➤ moved to softBody and cloth examples");
|
|
1973
2120
|
})();
|
|
1974
2121
|
}),
|
|
1975
|
-
(function(
|
|
2122
|
+
(function(T, A, f) {
|
|
1976
2123
|
var e = {};
|
|
1977
|
-
|
|
1978
|
-
var
|
|
2124
|
+
T.exports = e;
|
|
2125
|
+
var o = f(9), a = f(0), r = a.deprecated;
|
|
1979
2126
|
(function() {
|
|
1980
|
-
e.create = function(
|
|
2127
|
+
e.create = function(c) {
|
|
1981
2128
|
return a.extend({
|
|
1982
2129
|
buckets: {},
|
|
1983
2130
|
pairs: {},
|
|
1984
2131
|
pairsList: [],
|
|
1985
2132
|
bucketWidth: 48,
|
|
1986
2133
|
bucketHeight: 48
|
|
1987
|
-
},
|
|
1988
|
-
}, e.update = function(
|
|
1989
|
-
var t, i, s,
|
|
2134
|
+
}, c);
|
|
2135
|
+
}, e.update = function(c, n, h, l) {
|
|
2136
|
+
var t, i, s, u = h.world, m = c.buckets, x, P, B = !1;
|
|
1990
2137
|
for (t = 0; t < n.length; t++) {
|
|
1991
2138
|
var g = n[t];
|
|
1992
|
-
if (!(g.isSleeping && !
|
|
1993
|
-
var p = e._getRegion(
|
|
1994
|
-
if (!g.region || p.id !== g.region.id ||
|
|
1995
|
-
(!g.region ||
|
|
2139
|
+
if (!(g.isSleeping && !l) && !(u.bounds && (g.bounds.max.x < u.bounds.min.x || g.bounds.min.x > u.bounds.max.x || g.bounds.max.y < u.bounds.min.y || g.bounds.min.y > u.bounds.max.y))) {
|
|
2140
|
+
var p = e._getRegion(c, g);
|
|
2141
|
+
if (!g.region || p.id !== g.region.id || l) {
|
|
2142
|
+
(!g.region || l) && (g.region = p);
|
|
1996
2143
|
var y = e._regionUnion(p, g.region);
|
|
1997
2144
|
for (i = y.startCol; i <= y.endCol; i++) for (s = y.startRow; s <= y.endRow; s++) {
|
|
1998
2145
|
P = e._getBucketId(i, s), x = m[P];
|
|
1999
2146
|
var v = i >= p.startCol && i <= p.endCol && s >= p.startRow && s <= p.endRow, w = i >= g.region.startCol && i <= g.region.endCol && s >= g.region.startRow && s <= g.region.endRow;
|
|
2000
|
-
!v && w && w && x && e._bucketRemoveBody(
|
|
2147
|
+
!v && w && w && x && e._bucketRemoveBody(c, x, g), (g.region === p || v && !w || l) && (x || (x = e._createBucket(m, P)), e._bucketAddBody(c, x, g));
|
|
2001
2148
|
}
|
|
2002
|
-
g.region = p,
|
|
2149
|
+
g.region = p, B = !0;
|
|
2003
2150
|
}
|
|
2004
2151
|
}
|
|
2005
2152
|
}
|
|
2006
|
-
|
|
2007
|
-
}, r(e, "update", "Grid.update ➤ replaced by Matter.Detector"), e.clear = function(
|
|
2008
|
-
|
|
2009
|
-
}, r(e, "clear", "Grid.clear ➤ replaced by Matter.Detector"), e._regionUnion = function(
|
|
2010
|
-
var
|
|
2011
|
-
return e._createRegion(
|
|
2012
|
-
}, e._getRegion = function(
|
|
2013
|
-
var
|
|
2014
|
-
return e._createRegion(
|
|
2015
|
-
}, e._createRegion = function(
|
|
2153
|
+
B && (c.pairsList = e._createActivePairsList(c));
|
|
2154
|
+
}, r(e, "update", "Grid.update ➤ replaced by Matter.Detector"), e.clear = function(c) {
|
|
2155
|
+
c.buckets = {}, c.pairs = {}, c.pairsList = [];
|
|
2156
|
+
}, r(e, "clear", "Grid.clear ➤ replaced by Matter.Detector"), e._regionUnion = function(c, n) {
|
|
2157
|
+
var h = Math.min(c.startCol, n.startCol), l = Math.max(c.endCol, n.endCol), t = Math.min(c.startRow, n.startRow), i = Math.max(c.endRow, n.endRow);
|
|
2158
|
+
return e._createRegion(h, l, t, i);
|
|
2159
|
+
}, e._getRegion = function(c, n) {
|
|
2160
|
+
var h = n.bounds, l = Math.floor(h.min.x / c.bucketWidth), t = Math.floor(h.max.x / c.bucketWidth), i = Math.floor(h.min.y / c.bucketHeight), s = Math.floor(h.max.y / c.bucketHeight);
|
|
2161
|
+
return e._createRegion(l, t, i, s);
|
|
2162
|
+
}, e._createRegion = function(c, n, h, l) {
|
|
2016
2163
|
return {
|
|
2017
|
-
id:
|
|
2018
|
-
startCol:
|
|
2164
|
+
id: c + "," + n + "," + h + "," + l,
|
|
2165
|
+
startCol: c,
|
|
2019
2166
|
endCol: n,
|
|
2020
|
-
startRow:
|
|
2021
|
-
endRow:
|
|
2167
|
+
startRow: h,
|
|
2168
|
+
endRow: l
|
|
2022
2169
|
};
|
|
2023
|
-
}, e._getBucketId = function(
|
|
2024
|
-
return "C" +
|
|
2025
|
-
}, e._createBucket = function(
|
|
2026
|
-
return
|
|
2027
|
-
}, e._bucketAddBody = function(
|
|
2028
|
-
var
|
|
2170
|
+
}, e._getBucketId = function(c, n) {
|
|
2171
|
+
return "C" + c + "R" + n;
|
|
2172
|
+
}, e._createBucket = function(c, n) {
|
|
2173
|
+
return c[n] = [];
|
|
2174
|
+
}, e._bucketAddBody = function(c, n, h) {
|
|
2175
|
+
var l = c.pairs, t = o.id, i = n.length, s;
|
|
2029
2176
|
for (s = 0; s < i; s++) {
|
|
2030
|
-
var
|
|
2031
|
-
if (!(
|
|
2032
|
-
var m = t(
|
|
2033
|
-
x ? x[2] += 1 :
|
|
2177
|
+
var u = n[s];
|
|
2178
|
+
if (!(h.id === u.id || h.isStatic && u.isStatic)) {
|
|
2179
|
+
var m = t(h, u), x = l[m];
|
|
2180
|
+
x ? x[2] += 1 : l[m] = [
|
|
2181
|
+
h,
|
|
2034
2182
|
u,
|
|
2035
|
-
f,
|
|
2036
2183
|
1
|
|
2037
2184
|
];
|
|
2038
2185
|
}
|
|
2039
2186
|
}
|
|
2040
|
-
n.push(
|
|
2041
|
-
}, e._bucketRemoveBody = function(
|
|
2042
|
-
var
|
|
2043
|
-
n.splice(a.indexOf(n,
|
|
2187
|
+
n.push(h);
|
|
2188
|
+
}, e._bucketRemoveBody = function(c, n, h) {
|
|
2189
|
+
var l = c.pairs, t = o.id, i;
|
|
2190
|
+
n.splice(a.indexOf(n, h), 1);
|
|
2044
2191
|
var s = n.length;
|
|
2045
2192
|
for (i = 0; i < s; i++) {
|
|
2046
|
-
var
|
|
2047
|
-
|
|
2193
|
+
var u = l[t(h, n[i])];
|
|
2194
|
+
u && (u[2] -= 1);
|
|
2048
2195
|
}
|
|
2049
|
-
}, e._createActivePairsList = function(
|
|
2050
|
-
var n,
|
|
2196
|
+
}, e._createActivePairsList = function(c) {
|
|
2197
|
+
var n, h = c.pairs, l = a.keys(h), t = l.length, i = [], s;
|
|
2051
2198
|
for (s = 0; s < t; s++)
|
|
2052
|
-
n =
|
|
2199
|
+
n = h[l[s]], n[2] > 0 ? i.push(n) : delete h[l[s]];
|
|
2053
2200
|
return i;
|
|
2054
2201
|
};
|
|
2055
2202
|
})();
|
|
2056
2203
|
}),
|
|
2057
|
-
(function(
|
|
2204
|
+
(function(T, A, f) {
|
|
2058
2205
|
var e = {};
|
|
2059
|
-
|
|
2060
|
-
var
|
|
2206
|
+
T.exports = e;
|
|
2207
|
+
var o = f(3), a = f(7), r = f(14), c = f(5), n = f(13), h = f(10), l = f(6), t = f(0), i = f(1);
|
|
2061
2208
|
(function() {
|
|
2062
|
-
e.create = function(s,
|
|
2063
|
-
var m = (s ? s.mouse : null) || (
|
|
2064
|
-
m || (s && s.render && s.render.canvas ? m = r.create(s.render.canvas) :
|
|
2065
|
-
var x =
|
|
2209
|
+
e.create = function(s, u) {
|
|
2210
|
+
var m = (s ? s.mouse : null) || (u ? u.mouse : null);
|
|
2211
|
+
m || (s && s.render && s.render.canvas ? m = r.create(s.render.canvas) : u && u.element ? m = r.create(u.element) : (m = r.create(), t.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));
|
|
2212
|
+
var x = h.create({
|
|
2066
2213
|
label: "Mouse Constraint",
|
|
2067
2214
|
pointA: m.position,
|
|
2068
2215
|
pointB: {
|
|
@@ -2087,24 +2234,24 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2087
2234
|
mask: 4294967295,
|
|
2088
2235
|
group: 0
|
|
2089
2236
|
}
|
|
2090
|
-
},
|
|
2091
|
-
return
|
|
2092
|
-
var g =
|
|
2093
|
-
e.update(
|
|
2094
|
-
}),
|
|
2095
|
-
}, e.update = function(s,
|
|
2237
|
+
}, B = t.extend(P, u);
|
|
2238
|
+
return c.on(s, "beforeUpdate", function() {
|
|
2239
|
+
var g = l.allBodies(s.world);
|
|
2240
|
+
e.update(B, g), e._triggerEvents(B);
|
|
2241
|
+
}), B;
|
|
2242
|
+
}, e.update = function(s, u) {
|
|
2096
2243
|
var m = s.mouse, x = s.constraint, P = s.body;
|
|
2097
2244
|
if (m.button === 0) {
|
|
2098
2245
|
if (x.bodyB) a.set(x.bodyB, !1), x.pointA = m.position;
|
|
2099
2246
|
else
|
|
2100
|
-
for (var
|
|
2101
|
-
if (P =
|
|
2247
|
+
for (var B = 0; B < u.length; B++)
|
|
2248
|
+
if (P = u[B], i.contains(P.bounds, m.position) && n.canCollide(P.collisionFilter, s.collisionFilter)) for (var g = P.parts.length > 1 ? 1 : 0; g < P.parts.length; g++) {
|
|
2102
2249
|
var p = P.parts[g];
|
|
2103
|
-
if (
|
|
2250
|
+
if (o.contains(p.vertices, m.position)) {
|
|
2104
2251
|
x.pointA = m.position, x.bodyB = s.body = P, x.pointB = {
|
|
2105
2252
|
x: m.position.x - P.position.x,
|
|
2106
2253
|
y: m.position.y - P.position.y
|
|
2107
|
-
}, x.angleB = P.angle, a.set(P, !1),
|
|
2254
|
+
}, x.angleB = P.angle, a.set(P, !1), c.trigger(s, "startdrag", {
|
|
2108
2255
|
mouse: m,
|
|
2109
2256
|
body: P
|
|
2110
2257
|
});
|
|
@@ -2112,28 +2259,28 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2112
2259
|
}
|
|
2113
2260
|
}
|
|
2114
2261
|
} else
|
|
2115
|
-
x.bodyB = s.body = null, x.pointB = null, P &&
|
|
2262
|
+
x.bodyB = s.body = null, x.pointB = null, P && c.trigger(s, "enddrag", {
|
|
2116
2263
|
mouse: m,
|
|
2117
2264
|
body: P
|
|
2118
2265
|
});
|
|
2119
2266
|
}, e._triggerEvents = function(s) {
|
|
2120
|
-
var
|
|
2121
|
-
m.mousemove &&
|
|
2267
|
+
var u = s.mouse, m = u.sourceEvents;
|
|
2268
|
+
m.mousemove && c.trigger(s, "mousemove", { mouse: u }), m.mousedown && c.trigger(s, "mousedown", { mouse: u }), m.mouseup && c.trigger(s, "mouseup", { mouse: u }), r.clearSourceEvents(u);
|
|
2122
2269
|
};
|
|
2123
2270
|
})();
|
|
2124
2271
|
}),
|
|
2125
|
-
(function(
|
|
2272
|
+
(function(T, A, f) {
|
|
2126
2273
|
var e = {};
|
|
2127
|
-
|
|
2128
|
-
var
|
|
2274
|
+
T.exports = e;
|
|
2275
|
+
var o = f(2), a = f(8), r = f(1), c = f(12), n = f(3);
|
|
2129
2276
|
(function() {
|
|
2130
|
-
e.collides = function(
|
|
2131
|
-
for (var t = [], i =
|
|
2132
|
-
var P =
|
|
2133
|
-
if (m(P.bounds, s)) for (var p = g; p <
|
|
2277
|
+
e.collides = function(h, l) {
|
|
2278
|
+
for (var t = [], i = l.length, s = h.bounds, u = a.collides, m = r.overlaps, x = 0; x < i; x++) {
|
|
2279
|
+
var P = l[x], B = P.parts.length, g = B === 1 ? 0 : 1;
|
|
2280
|
+
if (m(P.bounds, s)) for (var p = g; p < B; p++) {
|
|
2134
2281
|
var y = P.parts[p];
|
|
2135
2282
|
if (m(y.bounds, s)) {
|
|
2136
|
-
var v =
|
|
2283
|
+
var v = u(y, h);
|
|
2137
2284
|
if (v) {
|
|
2138
2285
|
t.push(v);
|
|
2139
2286
|
break;
|
|
@@ -2142,25 +2289,25 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2142
2289
|
}
|
|
2143
2290
|
}
|
|
2144
2291
|
return t;
|
|
2145
|
-
}, e.ray = function(
|
|
2292
|
+
}, e.ray = function(h, l, t, i) {
|
|
2146
2293
|
i = i || 1e-100;
|
|
2147
|
-
for (var s =
|
|
2148
|
-
var p =
|
|
2294
|
+
for (var s = o.angle(l, t), u = o.magnitude(o.sub(l, t)), m = (t.x + l.x) * 0.5, x = (t.y + l.y) * 0.5, P = c.rectangle(m, x, u, i, { angle: s }), B = e.collides(P, h), g = 0; g < B.length; g += 1) {
|
|
2295
|
+
var p = B[g];
|
|
2149
2296
|
p.body = p.bodyB = p.bodyA;
|
|
2150
2297
|
}
|
|
2151
|
-
return
|
|
2152
|
-
}, e.region = function(
|
|
2153
|
-
for (var i = [], s = 0; s <
|
|
2154
|
-
var
|
|
2155
|
-
(m && !t || !m && t) && i.push(
|
|
2298
|
+
return B;
|
|
2299
|
+
}, e.region = function(h, l, t) {
|
|
2300
|
+
for (var i = [], s = 0; s < h.length; s++) {
|
|
2301
|
+
var u = h[s], m = r.overlaps(u.bounds, l);
|
|
2302
|
+
(m && !t || !m && t) && i.push(u);
|
|
2156
2303
|
}
|
|
2157
2304
|
return i;
|
|
2158
|
-
}, e.point = function(
|
|
2159
|
-
for (var t = [], i = 0; i <
|
|
2160
|
-
var s =
|
|
2161
|
-
if (r.contains(s.bounds,
|
|
2162
|
-
var m = s.parts[
|
|
2163
|
-
if (r.contains(m.bounds,
|
|
2305
|
+
}, e.point = function(h, l) {
|
|
2306
|
+
for (var t = [], i = 0; i < h.length; i++) {
|
|
2307
|
+
var s = h[i];
|
|
2308
|
+
if (r.contains(s.bounds, l)) for (var u = s.parts.length === 1 ? 0 : 1; u < s.parts.length; u++) {
|
|
2309
|
+
var m = s.parts[u];
|
|
2310
|
+
if (r.contains(m.bounds, l) && n.contains(m.vertices, l)) {
|
|
2164
2311
|
t.push(s);
|
|
2165
2312
|
break;
|
|
2166
2313
|
}
|
|
@@ -2170,10 +2317,10 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2170
2317
|
};
|
|
2171
2318
|
})();
|
|
2172
2319
|
}),
|
|
2173
|
-
(function(
|
|
2320
|
+
(function(T, A, f) {
|
|
2174
2321
|
var e = {};
|
|
2175
|
-
|
|
2176
|
-
var
|
|
2322
|
+
T.exports = e;
|
|
2323
|
+
var o = f(4), a = f(0), r = f(6), c = f(1), n = f(5), h = f(2), l = f(14);
|
|
2177
2324
|
(function() {
|
|
2178
2325
|
var t, i;
|
|
2179
2326
|
typeof window < "u" && (t = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(g) {
|
|
@@ -2268,36 +2415,36 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2268
2415
|
var C = p[S], M = C.bounds ? C.bounds.min : C.min || C.position || C, I = C.bounds ? C.bounds.max : C.max || C.position || C;
|
|
2269
2416
|
M && I && (M.x < w.min.x && (w.min.x = M.x), I.x > w.max.x && (w.max.x = I.x), M.y < w.min.y && (w.min.y = M.y), I.y > w.max.y && (w.max.y = I.y));
|
|
2270
2417
|
}
|
|
2271
|
-
var R = w.max.x - w.min.x + 2 * y.x, L = w.max.y - w.min.y + 2 * y.y,
|
|
2272
|
-
|
|
2418
|
+
var R = w.max.x - w.min.x + 2 * y.x, L = w.max.y - w.min.y + 2 * y.y, b = g.canvas.height, k = g.canvas.width / b, D = R / L, F = 1, H = 1;
|
|
2419
|
+
D > k ? H = D / k : F = k / D, g.options.hasBounds = !0, g.bounds.min.x = w.min.x, g.bounds.max.x = w.min.x + R * F, g.bounds.min.y = w.min.y, g.bounds.max.y = w.min.y + L * H, v && (g.bounds.min.x += R * 0.5 - R * F * 0.5, g.bounds.max.x += R * 0.5 - R * F * 0.5, g.bounds.min.y += L * 0.5 - L * H * 0.5, g.bounds.max.y += L * 0.5 - L * H * 0.5), g.bounds.min.x -= y.x, g.bounds.max.x -= y.x, g.bounds.min.y -= y.y, g.bounds.max.y -= y.y, g.mouse && (l.setScale(g.mouse, {
|
|
2273
2420
|
x: (g.bounds.max.x - g.bounds.min.x) / g.canvas.width,
|
|
2274
2421
|
y: (g.bounds.max.y - g.bounds.min.y) / g.canvas.height
|
|
2275
|
-
}),
|
|
2422
|
+
}), l.setOffset(g.mouse, g.bounds.min));
|
|
2276
2423
|
}, e.startViewTransform = function(g) {
|
|
2277
2424
|
var p = g.bounds.max.x - g.bounds.min.x, y = g.bounds.max.y - g.bounds.min.y, v = p / g.options.width, w = y / g.options.height;
|
|
2278
2425
|
g.context.setTransform(g.options.pixelRatio / v, 0, 0, g.options.pixelRatio / w, 0, 0), g.context.translate(-g.bounds.min.x, -g.bounds.min.y);
|
|
2279
2426
|
}, e.endViewTransform = function(g) {
|
|
2280
2427
|
g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
|
|
2281
2428
|
}, e.world = function(g, p) {
|
|
2282
|
-
var y = a.now(), v = g.engine, w = v.world, S = g.canvas, C = g.context, M = g.options, I = g.timing, R = r.allBodies(w), L = r.allConstraints(w),
|
|
2283
|
-
if (n.trigger(g, "beforeRender",
|
|
2284
|
-
for (
|
|
2285
|
-
var G = R[
|
|
2286
|
-
|
|
2429
|
+
var y = a.now(), v = g.engine, w = v.world, S = g.canvas, C = g.context, M = g.options, I = g.timing, R = r.allBodies(w), L = r.allConstraints(w), b = M.wireframes ? M.wireframeBackground : M.background, k = [], D = [], F, H = { timestamp: v.timing.timestamp };
|
|
2430
|
+
if (n.trigger(g, "beforeRender", H), g.currentBackground !== b && B(g, b), C.globalCompositeOperation = "source-in", C.fillStyle = "transparent", C.fillRect(0, 0, S.width, S.height), C.globalCompositeOperation = "source-over", M.hasBounds) {
|
|
2431
|
+
for (F = 0; F < R.length; F++) {
|
|
2432
|
+
var G = R[F];
|
|
2433
|
+
c.overlaps(G.bounds, g.bounds) && k.push(G);
|
|
2287
2434
|
}
|
|
2288
|
-
for (
|
|
2289
|
-
var
|
|
2290
|
-
Q && (
|
|
2435
|
+
for (F = 0; F < L.length; F++) {
|
|
2436
|
+
var V = L[F], Q = V.bodyA, X = V.bodyB, U = V.pointA, W = V.pointB;
|
|
2437
|
+
Q && (U = h.add(Q.position, V.pointA)), X && (W = h.add(X.position, V.pointB)), !(!U || !W) && (c.contains(g.bounds, U) || c.contains(g.bounds, W)) && D.push(V);
|
|
2291
2438
|
}
|
|
2292
|
-
e.startViewTransform(g), g.mouse && (
|
|
2439
|
+
e.startViewTransform(g), g.mouse && (l.setScale(g.mouse, {
|
|
2293
2440
|
x: (g.bounds.max.x - g.bounds.min.x) / g.options.width,
|
|
2294
2441
|
y: (g.bounds.max.y - g.bounds.min.y) / g.options.height
|
|
2295
|
-
}),
|
|
2442
|
+
}), l.setOffset(g.mouse, g.bounds.min));
|
|
2296
2443
|
} else
|
|
2297
|
-
|
|
2298
|
-
!M.wireframes || v.enableSleeping && M.showSleeping ? e.bodies(g, k, C) : (M.showConvexHulls && e.bodyConvexHulls(g, k, C), e.bodyWireframes(g, k, C)), M.showBounds && e.bodyBounds(g, k, C), (M.showAxes || M.showAngleIndicator) && e.bodyAxes(g, k, C), M.showPositions && e.bodyPositions(g, k, C), M.showVelocity && e.bodyVelocity(g, k, C), M.showIds && e.bodyIds(g, k, C), M.showSeparations && e.separations(g, v.pairs.list, C), M.showCollisions && e.collisions(g, v.pairs.list, C), M.showVertexNumbers && e.vertexNumbers(g, k, C), M.showMousePosition && e.mousePosition(g, g.mouse, C), e.constraints(
|
|
2444
|
+
D = L, k = R, g.options.pixelRatio !== 1 && g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
|
|
2445
|
+
!M.wireframes || v.enableSleeping && M.showSleeping ? e.bodies(g, k, C) : (M.showConvexHulls && e.bodyConvexHulls(g, k, C), e.bodyWireframes(g, k, C)), M.showBounds && e.bodyBounds(g, k, C), (M.showAxes || M.showAngleIndicator) && e.bodyAxes(g, k, C), M.showPositions && e.bodyPositions(g, k, C), M.showVelocity && e.bodyVelocity(g, k, C), M.showIds && e.bodyIds(g, k, C), M.showSeparations && e.separations(g, v.pairs.list, C), M.showCollisions && e.collisions(g, v.pairs.list, C), M.showVertexNumbers && e.vertexNumbers(g, k, C), M.showMousePosition && e.mousePosition(g, g.mouse, C), e.constraints(D, C), M.hasBounds && e.endViewTransform(g), n.trigger(g, "afterRender", H), I.lastElapsed = a.now() - y;
|
|
2299
2446
|
}, e.stats = function(g, p, y) {
|
|
2300
|
-
for (var v = g.engine, w = v.world, S = r.allBodies(w), C = 0, M = 55, I = 44, R = 0, L = 0,
|
|
2447
|
+
for (var v = g.engine, w = v.world, S = r.allBodies(w), C = 0, M = 55, I = 44, R = 0, L = 0, b = 0; b < S.length; b += 1) C += S[b].parts.length;
|
|
2301
2448
|
var k = {
|
|
2302
2449
|
Part: C,
|
|
2303
2450
|
Body: S.length,
|
|
@@ -2306,24 +2453,24 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2306
2453
|
Pair: v.pairs.list.length
|
|
2307
2454
|
};
|
|
2308
2455
|
p.fillStyle = "#0e0f19", p.fillRect(R, L, M * 5.5, I), p.font = "12px Arial", p.textBaseline = "top", p.textAlign = "right";
|
|
2309
|
-
for (var
|
|
2310
|
-
var
|
|
2311
|
-
p.fillStyle = "#aaa", p.fillText(
|
|
2456
|
+
for (var D in k) {
|
|
2457
|
+
var F = k[D];
|
|
2458
|
+
p.fillStyle = "#aaa", p.fillText(D, R + M, L + 8), p.fillStyle = "#eee", p.fillText(F, R + M, L + 26), R += M;
|
|
2312
2459
|
}
|
|
2313
2460
|
}, e.performance = function(g, p) {
|
|
2314
|
-
var y = g.engine, v = g.timing, w = v.deltaHistory, S = v.elapsedHistory, C = v.timestampElapsedHistory, M = v.engineDeltaHistory, I = v.engineUpdatesHistory, R = v.engineElapsedHistory, L = y.timing.lastUpdatesPerFrame,
|
|
2315
|
-
p.fillStyle = "#0e0f19", p.fillRect(0, 50,
|
|
2461
|
+
var y = g.engine, v = g.timing, w = v.deltaHistory, S = v.elapsedHistory, C = v.timestampElapsedHistory, M = v.engineDeltaHistory, I = v.engineUpdatesHistory, R = v.engineElapsedHistory, L = y.timing.lastUpdatesPerFrame, b = y.timing.lastDelta, k = u(w), D = u(S), F = u(M), H = u(I), G = u(R), V = u(C) / k || 0, Q = Math.round(k / b), X = 1e3 / k || 0, U = 4, W = 12, N = 60, J = 34, K = 10, Y = 69;
|
|
2462
|
+
p.fillStyle = "#0e0f19", p.fillRect(0, 50, W * 5 + N * 6 + 22, J), e.status(p, K, Y, N, U, w.length, Math.round(X) + " fps", X / e._goodFps, function(z) {
|
|
2316
2463
|
return w[z] / k - 1;
|
|
2317
|
-
}), e.status(p,
|
|
2318
|
-
return M[z] /
|
|
2319
|
-
}), e.status(p,
|
|
2320
|
-
return I[z] /
|
|
2321
|
-
}), e.status(p,
|
|
2464
|
+
}), e.status(p, K + W + N, Y, N, U, M.length, b.toFixed(2) + " dt", e._goodDelta / b, function(z) {
|
|
2465
|
+
return M[z] / F - 1;
|
|
2466
|
+
}), e.status(p, K + (W + N) * 2, Y, N, U, I.length, L + " upf", Math.pow(a.clamp(H / Q || 1, 0, 1), 4), function(z) {
|
|
2467
|
+
return I[z] / H - 1;
|
|
2468
|
+
}), e.status(p, K + (W + N) * 3, Y, N, U, R.length, G.toFixed(2) + " ut", 1 - L * G / e._goodFps, function(z) {
|
|
2322
2469
|
return R[z] / G - 1;
|
|
2323
|
-
}), e.status(p,
|
|
2324
|
-
return S[z] /
|
|
2325
|
-
}), e.status(p,
|
|
2326
|
-
return (C[z] / w[z] /
|
|
2470
|
+
}), e.status(p, K + (W + N) * 4, Y, N, U, S.length, D.toFixed(2) + " rt", 1 - D / e._goodFps, function(z) {
|
|
2471
|
+
return S[z] / D - 1;
|
|
2472
|
+
}), e.status(p, K + (W + N) * 5, Y, N, U, C.length, V.toFixed(2) + " x", V * V * V, function(z) {
|
|
2473
|
+
return (C[z] / w[z] / V || 0) - 1;
|
|
2327
2474
|
});
|
|
2328
2475
|
}, e.status = function(g, p, y, v, w, S, C, M, I) {
|
|
2329
2476
|
g.strokeStyle = "#888", g.fillStyle = "#444", g.lineWidth = 1, g.fillRect(p, y + 7, v, 1), g.beginPath(), g.moveTo(p, y + 7 - w * a.clamp(0.4 * I(0), -2, 2));
|
|
@@ -2334,12 +2481,12 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2334
2481
|
var w = g[v];
|
|
2335
2482
|
if (!(!w.render.visible || !w.pointA || !w.pointB)) {
|
|
2336
2483
|
var S = w.bodyA, C = w.bodyB, M, I;
|
|
2337
|
-
if (S ? M =
|
|
2484
|
+
if (S ? M = h.add(S.position, w.pointA) : M = w.pointA, w.render.type === "pin")
|
|
2338
2485
|
y.beginPath(), y.arc(M.x, M.y, 3, 0, 2 * Math.PI), y.closePath();
|
|
2339
2486
|
else {
|
|
2340
|
-
if (C ? I =
|
|
2341
|
-
for (var R =
|
|
2342
|
-
k =
|
|
2487
|
+
if (C ? I = h.add(C.position, w.pointB) : I = w.pointB, y.beginPath(), y.moveTo(M.x, M.y), w.render.type === "spring")
|
|
2488
|
+
for (var R = h.sub(I, M), L = h.perp(h.normalise(R)), b = Math.ceil(a.clamp(w.length / 5, 12, 20)), k, D = 1; D < b; D += 1)
|
|
2489
|
+
k = D % 2 === 0 ? 1 : -1, y.lineTo(M.x + R.x * (D / b) + L.x * k * 4, M.y + R.y * (D / b) + L.y * k * 4);
|
|
2343
2490
|
y.lineTo(I.x, I.y);
|
|
2344
2491
|
}
|
|
2345
2492
|
w.render.lineWidth && (y.lineWidth = w.render.lineWidth, y.strokeStyle = w.render.strokeStyle, y.stroke()), w.render.anchors && (y.fillStyle = w.render.strokeStyle, y.beginPath(), y.arc(M.x, M.y, 3, 0, 2 * Math.PI), y.arc(I.x, I.y, 3, 0, 2 * Math.PI), y.closePath(), y.fill());
|
|
@@ -2354,8 +2501,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2354
2501
|
for (R = C.parts.length > 1 ? 1 : 0; R < C.parts.length; R++)
|
|
2355
2502
|
if (M = C.parts[R], !!M.render.visible) {
|
|
2356
2503
|
if (w.showSleeping && C.isSleeping ? v.globalAlpha = 0.5 * M.render.opacity : M.render.opacity !== 1 && (v.globalAlpha = M.render.opacity), M.render.sprite && M.render.sprite.texture && !w.wireframes) {
|
|
2357
|
-
var L = M.render.sprite,
|
|
2358
|
-
v.translate(M.position.x, M.position.y), v.rotate(M.angle), v.drawImage(
|
|
2504
|
+
var L = M.render.sprite, b = P(g, L.texture);
|
|
2505
|
+
v.translate(M.position.x, M.position.y), v.rotate(M.angle), v.drawImage(b, b.width * -L.xOffset * L.xScale, b.height * -L.yOffset * L.yScale, b.width * L.xScale, b.height * L.yScale), v.rotate(-M.angle), v.translate(-M.position.x, -M.position.y);
|
|
2359
2506
|
} else {
|
|
2360
2507
|
if (M.circleRadius)
|
|
2361
2508
|
v.beginPath(), v.arc(M.position.x, M.position.y, M.circleRadius, 0, 2 * Math.PI);
|
|
@@ -2421,8 +2568,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2421
2568
|
if (R.render.visible)
|
|
2422
2569
|
if (w.showAxes) for (M = L.length > 1 ? 1 : 0; M < L.length; M++)
|
|
2423
2570
|
for (S = L[M], I = 0; I < S.axes.length; I++) {
|
|
2424
|
-
var
|
|
2425
|
-
v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x +
|
|
2571
|
+
var b = S.axes[I];
|
|
2572
|
+
v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + b.x * 20, S.position.y + b.y * 20);
|
|
2426
2573
|
}
|
|
2427
2574
|
else for (M = L.length > 1 ? 1 : 0; M < L.length; M++)
|
|
2428
2575
|
for (S = L[M], I = 0; I < S.axes.length; I++)
|
|
@@ -2446,7 +2593,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2446
2593
|
for (var w = 0; w < p.length; w++) {
|
|
2447
2594
|
var S = p[w];
|
|
2448
2595
|
if (S.render.visible) {
|
|
2449
|
-
var C =
|
|
2596
|
+
var C = o.getVelocity(S);
|
|
2450
2597
|
v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + C.x, S.position.y + C.y);
|
|
2451
2598
|
}
|
|
2452
2599
|
}
|
|
@@ -2471,8 +2618,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2471
2618
|
}
|
|
2472
2619
|
for (w.wireframes ? v.fillStyle = "rgba(255,255,255,0.7)" : v.fillStyle = "orange", v.fill(), v.beginPath(), M = 0; M < p.length; M++)
|
|
2473
2620
|
if (S = p[M], !!S.isActive && (C = S.collision, S.contactCount > 0)) {
|
|
2474
|
-
var L = S.contacts[0].vertex.x,
|
|
2475
|
-
S.contactCount === 2 && (L = (S.contacts[0].vertex.x + S.contacts[1].vertex.x) / 2,
|
|
2621
|
+
var L = S.contacts[0].vertex.x, b = S.contacts[0].vertex.y;
|
|
2622
|
+
S.contactCount === 2 && (L = (S.contacts[0].vertex.x + S.contacts[1].vertex.x) / 2, b = (S.contacts[0].vertex.y + S.contacts[1].vertex.y) / 2), C.bodyB === C.supports[0].body || C.bodyA.isStatic === !0 ? v.moveTo(L - C.normal.x * 8, b - C.normal.y * 8) : v.moveTo(L + C.normal.x * 8, b + C.normal.y * 8), v.lineTo(L, b);
|
|
2476
2623
|
}
|
|
2477
2624
|
w.wireframes ? v.strokeStyle = "rgba(255,165,0,0.7)" : v.strokeStyle = "orange", v.lineWidth = 1, v.stroke();
|
|
2478
2625
|
}, e.separations = function(g, p, y) {
|
|
@@ -2492,14 +2639,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2492
2639
|
p.scale(1 / I, 1 / R), p.translate(-v.bounds.min.x, -v.bounds.min.y);
|
|
2493
2640
|
}
|
|
2494
2641
|
for (var L = 0; L < y.length; L++) {
|
|
2495
|
-
var
|
|
2496
|
-
switch (p.translate(0.5, 0.5), p.lineWidth = 1, p.strokeStyle = "rgba(255,165,0,0.9)", p.setLineDash([1, 2]),
|
|
2642
|
+
var b = y[L].data;
|
|
2643
|
+
switch (p.translate(0.5, 0.5), p.lineWidth = 1, p.strokeStyle = "rgba(255,165,0,0.9)", p.setLineDash([1, 2]), b.type) {
|
|
2497
2644
|
case "body":
|
|
2498
|
-
S =
|
|
2645
|
+
S = b.bounds, p.beginPath(), p.rect(Math.floor(S.min.x - 3), Math.floor(S.min.y - 3), Math.floor(S.max.x - S.min.x + 6), Math.floor(S.max.y - S.min.y + 6)), p.closePath(), p.stroke();
|
|
2499
2646
|
break;
|
|
2500
2647
|
case "constraint":
|
|
2501
|
-
var k =
|
|
2502
|
-
|
|
2648
|
+
var k = b.pointA;
|
|
2649
|
+
b.bodyA && (k = b.pointB), p.beginPath(), p.arc(k.x, k.y, 10, 0, 2 * Math.PI), p.closePath(), p.stroke();
|
|
2503
2650
|
break;
|
|
2504
2651
|
}
|
|
2505
2652
|
p.setLineDash([]), p.translate(-0.5, -0.5);
|
|
@@ -2509,7 +2656,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2509
2656
|
var s = function(g, p) {
|
|
2510
2657
|
var y = g.engine, v = g.timing, w = v.historySize, S = y.timing.timestamp;
|
|
2511
2658
|
v.delta = p - v.lastTime || e._goodDelta, v.lastTime = p, v.timestampElapsed = S - v.lastTimestamp || 0, v.lastTimestamp = S, v.deltaHistory.unshift(v.delta), v.deltaHistory.length = Math.min(v.deltaHistory.length, w), v.engineDeltaHistory.unshift(y.timing.lastDelta), v.engineDeltaHistory.length = Math.min(v.engineDeltaHistory.length, w), v.timestampElapsedHistory.unshift(v.timestampElapsed), v.timestampElapsedHistory.length = Math.min(v.timestampElapsedHistory.length, w), v.engineUpdatesHistory.unshift(y.timing.lastUpdatesPerFrame), v.engineUpdatesHistory.length = Math.min(v.engineUpdatesHistory.length, w), v.engineElapsedHistory.unshift(y.timing.lastElapsed), v.engineElapsedHistory.length = Math.min(v.engineElapsedHistory.length, w), v.elapsedHistory.unshift(v.lastElapsed), v.elapsedHistory.length = Math.min(v.elapsedHistory.length, w);
|
|
2512
|
-
},
|
|
2659
|
+
}, u = function(g) {
|
|
2513
2660
|
for (var p = 0, y = 0; y < g.length; y += 1) p += g[y];
|
|
2514
2661
|
return p / g.length || 0;
|
|
2515
2662
|
}, m = function(g, p) {
|
|
@@ -2525,19 +2672,19 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2525
2672
|
}, P = function(g, p) {
|
|
2526
2673
|
var y = g.textures[p];
|
|
2527
2674
|
return y || (y = g.textures[p] = new Image(), y.src = p, y);
|
|
2528
|
-
},
|
|
2675
|
+
}, B = function(g, p) {
|
|
2529
2676
|
var y = p;
|
|
2530
2677
|
/(jpg|gif|png)$/.test(p) && (y = "url(" + p + ")"), g.canvas.style.background = y, g.canvas.style.backgroundSize = "contain", g.currentBackground = p;
|
|
2531
2678
|
};
|
|
2532
2679
|
})();
|
|
2533
2680
|
}),
|
|
2534
|
-
(function(
|
|
2681
|
+
(function(T, A, f) {
|
|
2535
2682
|
var e = {};
|
|
2536
|
-
|
|
2537
|
-
var
|
|
2683
|
+
T.exports = e;
|
|
2684
|
+
var o = f(5), a = f(17), r = f(0);
|
|
2538
2685
|
(function() {
|
|
2539
2686
|
e._maxFrameDelta = 1e3 / 15, e._frameDeltaFallback = 1e3 / 60, e._timeBufferMargin = 1.5, e._elapsedNextEstimate = 1, e._smoothingLowerBound = 0.1, e._smoothingUpperBound = 0.9, e.create = function(n) {
|
|
2540
|
-
var
|
|
2687
|
+
var h = r.extend({
|
|
2541
2688
|
delta: 16.666666666666668,
|
|
2542
2689
|
frameDelta: null,
|
|
2543
2690
|
frameDeltaSmoothing: !0,
|
|
@@ -2552,74 +2699,74 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2552
2699
|
lastUpdatesDeferred: 0,
|
|
2553
2700
|
enabled: !0
|
|
2554
2701
|
}, n);
|
|
2555
|
-
return
|
|
2556
|
-
}, e.run = function(n,
|
|
2557
|
-
return n.timeBuffer = e._frameDeltaFallback, (function
|
|
2558
|
-
n.frameRequestId = e._onNextFrame(n,
|
|
2702
|
+
return h.fps = 0, h;
|
|
2703
|
+
}, e.run = function(n, h) {
|
|
2704
|
+
return n.timeBuffer = e._frameDeltaFallback, (function l(t) {
|
|
2705
|
+
n.frameRequestId = e._onNextFrame(n, l), t && n.enabled && e.tick(n, h, t);
|
|
2559
2706
|
})(), n;
|
|
2560
|
-
}, e.tick = function(n,
|
|
2561
|
-
var t = r.now(), i = n.delta, s = 0,
|
|
2562
|
-
if ((!
|
|
2563
|
-
n.frameDeltaHistory.push(
|
|
2707
|
+
}, e.tick = function(n, h, l) {
|
|
2708
|
+
var t = r.now(), i = n.delta, s = 0, u = l - n.timeLastTick;
|
|
2709
|
+
if ((!u || !n.timeLastTick || u > Math.max(e._maxFrameDelta, n.maxFrameTime)) && (u = n.frameDelta || e._frameDeltaFallback), n.frameDeltaSmoothing) {
|
|
2710
|
+
n.frameDeltaHistory.push(u), n.frameDeltaHistory = n.frameDeltaHistory.slice(-n.frameDeltaHistorySize);
|
|
2564
2711
|
var m = n.frameDeltaHistory.slice(0).sort();
|
|
2565
|
-
|
|
2566
|
-
}
|
|
2567
|
-
n.frameDeltaSnapping && (
|
|
2568
|
-
var x = n.maxUpdates || Math.ceil(n.maxFrameTime / i), P = { timestamp:
|
|
2569
|
-
|
|
2570
|
-
for (var
|
|
2571
|
-
|
|
2572
|
-
var g = r.now() - t, p = r.now() -
|
|
2712
|
+
u = c(n.frameDeltaHistory.slice(m.length * e._smoothingLowerBound, m.length * e._smoothingUpperBound)) || u;
|
|
2713
|
+
}
|
|
2714
|
+
n.frameDeltaSnapping && (u = 1e3 / Math.round(1e3 / u)), n.frameDelta = u, n.timeLastTick = l, n.timeBuffer += n.frameDelta, n.timeBuffer = r.clamp(n.timeBuffer, 0, n.frameDelta + i * e._timeBufferMargin), n.lastUpdatesDeferred = 0;
|
|
2715
|
+
var x = n.maxUpdates || Math.ceil(n.maxFrameTime / i), P = { timestamp: h.timing.timestamp };
|
|
2716
|
+
o.trigger(n, "beforeTick", P), o.trigger(n, "tick", P);
|
|
2717
|
+
for (var B = r.now(); i > 0 && n.timeBuffer >= i * e._timeBufferMargin; ) {
|
|
2718
|
+
o.trigger(n, "beforeUpdate", P), a.update(h, i), o.trigger(n, "afterUpdate", P), n.timeBuffer -= i, s += 1;
|
|
2719
|
+
var g = r.now() - t, p = r.now() - B, y = g + e._elapsedNextEstimate * p / s;
|
|
2573
2720
|
if (s >= x || y > n.maxFrameTime) {
|
|
2574
2721
|
n.lastUpdatesDeferred = Math.round(Math.max(0, n.timeBuffer / i - e._timeBufferMargin));
|
|
2575
2722
|
break;
|
|
2576
2723
|
}
|
|
2577
2724
|
}
|
|
2578
|
-
|
|
2725
|
+
h.timing.lastUpdatesPerFrame = s, o.trigger(n, "afterTick", P), n.frameDeltaHistory.length >= 100 && (n.lastUpdatesDeferred && Math.round(n.frameDelta / i) > x ? r.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs.") : n.lastUpdatesDeferred && r.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."), typeof n.isFixed < "u" && r.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."), (n.deltaMin || n.deltaMax) && r.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."), n.fps !== 0 && r.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."));
|
|
2579
2726
|
}, e.stop = function(n) {
|
|
2580
2727
|
e._cancelNextFrame(n);
|
|
2581
|
-
}, e._onNextFrame = function(n,
|
|
2582
|
-
if (typeof window < "u" && window.requestAnimationFrame) n.frameRequestId = window.requestAnimationFrame(
|
|
2728
|
+
}, e._onNextFrame = function(n, h) {
|
|
2729
|
+
if (typeof window < "u" && window.requestAnimationFrame) n.frameRequestId = window.requestAnimationFrame(h);
|
|
2583
2730
|
else throw new Error("Matter.Runner: missing required global window.requestAnimationFrame.");
|
|
2584
2731
|
return n.frameRequestId;
|
|
2585
2732
|
}, e._cancelNextFrame = function(n) {
|
|
2586
2733
|
if (typeof window < "u" && window.cancelAnimationFrame) window.cancelAnimationFrame(n.frameRequestId);
|
|
2587
2734
|
else throw new Error("Matter.Runner: missing required global window.cancelAnimationFrame.");
|
|
2588
2735
|
};
|
|
2589
|
-
var
|
|
2590
|
-
for (var
|
|
2591
|
-
return
|
|
2736
|
+
var c = function(n) {
|
|
2737
|
+
for (var h = 0, l = n.length, t = 0; t < l; t += 1) h += n[t];
|
|
2738
|
+
return h / l || 0;
|
|
2592
2739
|
};
|
|
2593
2740
|
})();
|
|
2594
2741
|
}),
|
|
2595
|
-
(function(
|
|
2742
|
+
(function(T, A, f) {
|
|
2596
2743
|
var e = {};
|
|
2597
|
-
|
|
2598
|
-
var
|
|
2744
|
+
T.exports = e;
|
|
2745
|
+
var o = f(8), a = f(0).deprecated;
|
|
2599
2746
|
(function() {
|
|
2600
|
-
e.collides = function(r,
|
|
2601
|
-
return
|
|
2747
|
+
e.collides = function(r, c) {
|
|
2748
|
+
return o.collides(r, c);
|
|
2602
2749
|
}, a(e, "collides", "SAT.collides ➤ replaced by Collision.collides");
|
|
2603
2750
|
})();
|
|
2604
2751
|
}),
|
|
2605
|
-
(function(
|
|
2752
|
+
(function(T, A, f) {
|
|
2606
2753
|
var e = {};
|
|
2607
|
-
|
|
2608
|
-
var
|
|
2754
|
+
T.exports = e, f(1);
|
|
2755
|
+
var o = f(0);
|
|
2609
2756
|
(function() {
|
|
2610
2757
|
e.pathToVertices = function(a, r) {
|
|
2611
|
-
typeof window < "u" && !("SVGPathSeg" in window) &&
|
|
2612
|
-
var
|
|
2758
|
+
typeof window < "u" && !("SVGPathSeg" in window) && o.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");
|
|
2759
|
+
var c, n, h, l, t, i, s, u, m, x, P = [], B, g, p = 0, y = 0, v = 0;
|
|
2613
2760
|
r = r || 15;
|
|
2614
2761
|
var w = function(C, M, I) {
|
|
2615
2762
|
var R = I % 2 === 1 && I > 1;
|
|
2616
2763
|
if (!m || C != m.x || M != m.y) {
|
|
2617
|
-
m && R ? (
|
|
2764
|
+
m && R ? (B = m.x, g = m.y) : (B = 0, g = 0);
|
|
2618
2765
|
var L = {
|
|
2619
|
-
x:
|
|
2766
|
+
x: B + C,
|
|
2620
2767
|
y: g + M
|
|
2621
2768
|
};
|
|
2622
|
-
(R || !m) && (m = L), P.push(L), y =
|
|
2769
|
+
(R || !m) && (m = L), P.push(L), y = B + C, v = g + M;
|
|
2623
2770
|
}
|
|
2624
2771
|
}, S = function(C) {
|
|
2625
2772
|
var M = C.pathSegTypeAsLetter.toUpperCase();
|
|
@@ -2643,11 +2790,11 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2643
2790
|
w(y, v, C.pathSegType);
|
|
2644
2791
|
}
|
|
2645
2792
|
};
|
|
2646
|
-
for (e._svgPathToAbsolute(a),
|
|
2647
|
-
for (s = i.concat(); p <
|
|
2648
|
-
if (x = a.getPathSegAtLength(p), t = i[x], t !=
|
|
2793
|
+
for (e._svgPathToAbsolute(a), h = a.getTotalLength(), i = [], c = 0; c < a.pathSegList.numberOfItems; c += 1) i.push(a.pathSegList.getItem(c));
|
|
2794
|
+
for (s = i.concat(); p < h; ) {
|
|
2795
|
+
if (x = a.getPathSegAtLength(p), t = i[x], t != u) {
|
|
2649
2796
|
for (; s.length && s[0] != t; ) S(s.shift());
|
|
2650
|
-
|
|
2797
|
+
u = t;
|
|
2651
2798
|
}
|
|
2652
2799
|
switch (t.pathSegTypeAsLetter.toUpperCase()) {
|
|
2653
2800
|
case "C":
|
|
@@ -2655,80 +2802,80 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
|
|
|
2655
2802
|
case "S":
|
|
2656
2803
|
case "Q":
|
|
2657
2804
|
case "A":
|
|
2658
|
-
|
|
2805
|
+
l = a.getPointAtLength(p), w(l.x, l.y, 0);
|
|
2659
2806
|
break;
|
|
2660
2807
|
}
|
|
2661
2808
|
p += r;
|
|
2662
2809
|
}
|
|
2663
|
-
for (
|
|
2810
|
+
for (c = 0, n = s.length; c < n; ++c) S(s[c]);
|
|
2664
2811
|
return P;
|
|
2665
2812
|
}, e._svgPathToAbsolute = function(a) {
|
|
2666
|
-
for (var r,
|
|
2667
|
-
var P = i.getItem(x),
|
|
2668
|
-
if (/[MLHVCSQTA]/.test(
|
|
2669
|
-
"x" in P && (s = P.x), "y" in P && (
|
|
2813
|
+
for (var r, c, n, h, l, t, i = a.pathSegList, s = 0, u = 0, m = i.numberOfItems, x = 0; x < m; ++x) {
|
|
2814
|
+
var P = i.getItem(x), B = P.pathSegTypeAsLetter;
|
|
2815
|
+
if (/[MLHVCSQTA]/.test(B))
|
|
2816
|
+
"x" in P && (s = P.x), "y" in P && (u = P.y);
|
|
2670
2817
|
else
|
|
2671
|
-
switch ("x1" in P && (n = s + P.x1), "x2" in P && (
|
|
2818
|
+
switch ("x1" in P && (n = s + P.x1), "x2" in P && (l = s + P.x2), "y1" in P && (h = u + P.y1), "y2" in P && (t = u + P.y2), "x" in P && (s += P.x), "y" in P && (u += P.y), B) {
|
|
2672
2819
|
case "m":
|
|
2673
|
-
i.replaceItem(a.createSVGPathSegMovetoAbs(s,
|
|
2820
|
+
i.replaceItem(a.createSVGPathSegMovetoAbs(s, u), x);
|
|
2674
2821
|
break;
|
|
2675
2822
|
case "l":
|
|
2676
|
-
i.replaceItem(a.createSVGPathSegLinetoAbs(s,
|
|
2823
|
+
i.replaceItem(a.createSVGPathSegLinetoAbs(s, u), x);
|
|
2677
2824
|
break;
|
|
2678
2825
|
case "h":
|
|
2679
2826
|
i.replaceItem(a.createSVGPathSegLinetoHorizontalAbs(s), x);
|
|
2680
2827
|
break;
|
|
2681
2828
|
case "v":
|
|
2682
|
-
i.replaceItem(a.createSVGPathSegLinetoVerticalAbs(
|
|
2829
|
+
i.replaceItem(a.createSVGPathSegLinetoVerticalAbs(u), x);
|
|
2683
2830
|
break;
|
|
2684
2831
|
case "c":
|
|
2685
|
-
i.replaceItem(a.createSVGPathSegCurvetoCubicAbs(s,
|
|
2832
|
+
i.replaceItem(a.createSVGPathSegCurvetoCubicAbs(s, u, n, h, l, t), x);
|
|
2686
2833
|
break;
|
|
2687
2834
|
case "s":
|
|
2688
|
-
i.replaceItem(a.createSVGPathSegCurvetoCubicSmoothAbs(s,
|
|
2835
|
+
i.replaceItem(a.createSVGPathSegCurvetoCubicSmoothAbs(s, u, l, t), x);
|
|
2689
2836
|
break;
|
|
2690
2837
|
case "q":
|
|
2691
|
-
i.replaceItem(a.createSVGPathSegCurvetoQuadraticAbs(s,
|
|
2838
|
+
i.replaceItem(a.createSVGPathSegCurvetoQuadraticAbs(s, u, n, h), x);
|
|
2692
2839
|
break;
|
|
2693
2840
|
case "t":
|
|
2694
|
-
i.replaceItem(a.createSVGPathSegCurvetoQuadraticSmoothAbs(s,
|
|
2841
|
+
i.replaceItem(a.createSVGPathSegCurvetoQuadraticSmoothAbs(s, u), x);
|
|
2695
2842
|
break;
|
|
2696
2843
|
case "a":
|
|
2697
|
-
i.replaceItem(a.createSVGPathSegArcAbs(s,
|
|
2844
|
+
i.replaceItem(a.createSVGPathSegArcAbs(s, u, P.r1, P.r2, P.angle, P.largeArcFlag, P.sweepFlag), x);
|
|
2698
2845
|
break;
|
|
2699
2846
|
case "z":
|
|
2700
2847
|
case "Z":
|
|
2701
|
-
s = r,
|
|
2848
|
+
s = r, u = c;
|
|
2702
2849
|
break;
|
|
2703
2850
|
}
|
|
2704
|
-
(
|
|
2851
|
+
(B == "M" || B == "m") && (r = s, c = u);
|
|
2705
2852
|
}
|
|
2706
2853
|
};
|
|
2707
2854
|
})();
|
|
2708
2855
|
}),
|
|
2709
|
-
(function(
|
|
2856
|
+
(function(T, A, f) {
|
|
2710
2857
|
var e = {};
|
|
2711
|
-
|
|
2712
|
-
var
|
|
2713
|
-
|
|
2714
|
-
e.create =
|
|
2858
|
+
T.exports = e;
|
|
2859
|
+
var o = f(6);
|
|
2860
|
+
f(0), (function() {
|
|
2861
|
+
e.create = o.create, e.add = o.add, e.remove = o.remove, e.clear = o.clear, e.addComposite = o.addComposite, e.addBody = o.addBody, e.addConstraint = o.addConstraint;
|
|
2715
2862
|
})();
|
|
2716
2863
|
})
|
|
2717
2864
|
]);
|
|
2718
2865
|
});
|
|
2719
|
-
})),
|
|
2720
|
-
function
|
|
2721
|
-
return d < E ? E : d >
|
|
2866
|
+
})), O = Qe();
|
|
2867
|
+
function Ze(d, E, T) {
|
|
2868
|
+
return d < E ? E : d > T ? T : d;
|
|
2722
2869
|
}
|
|
2723
|
-
function
|
|
2870
|
+
function Z(d) {
|
|
2724
2871
|
const E = d.plugin.ballId;
|
|
2725
2872
|
return typeof E == "number" ? E : d.id;
|
|
2726
2873
|
}
|
|
2727
|
-
function
|
|
2728
|
-
return
|
|
2874
|
+
function Je(d, E, T, A) {
|
|
2875
|
+
return Ze(Math.floor((d - E) / T), 0, A - 1);
|
|
2729
2876
|
}
|
|
2730
|
-
var
|
|
2731
|
-
function
|
|
2877
|
+
var je = 0.18, qe = 0.12, _e = 420, et = 0.12, tt = 180, it = 2, nt = 5, st = 600, rt = 2, at = 25e3, ot = 0.15;
|
|
2878
|
+
function xe(d, E) {
|
|
2732
2879
|
return {
|
|
2733
2880
|
x: d,
|
|
2734
2881
|
y: E,
|
|
@@ -2740,10 +2887,10 @@ function pe(d, E) {
|
|
|
2740
2887
|
aliveMs: 0
|
|
2741
2888
|
};
|
|
2742
2889
|
}
|
|
2743
|
-
var
|
|
2890
|
+
var lt = class {
|
|
2744
2891
|
tracker = /* @__PURE__ */ new Map();
|
|
2745
|
-
track(d, E,
|
|
2746
|
-
this.tracker.set(d,
|
|
2892
|
+
track(d, E, T) {
|
|
2893
|
+
this.tracker.set(d, xe(E, T));
|
|
2747
2894
|
}
|
|
2748
2895
|
untrack(d) {
|
|
2749
2896
|
this.tracker.delete(d);
|
|
@@ -2751,101 +2898,101 @@ var Ze = class {
|
|
|
2751
2898
|
clear() {
|
|
2752
2899
|
this.tracker.clear();
|
|
2753
2900
|
}
|
|
2754
|
-
process(d, E,
|
|
2755
|
-
const
|
|
2756
|
-
for (const
|
|
2757
|
-
const a =
|
|
2758
|
-
|
|
2759
|
-
const r = this.tracker.get(a) ??
|
|
2760
|
-
if (
|
|
2761
|
-
|
|
2901
|
+
process(d, E, T) {
|
|
2902
|
+
const A = [], f = /* @__PURE__ */ new Set(), e = [];
|
|
2903
|
+
for (const o of E) {
|
|
2904
|
+
const a = Z(o);
|
|
2905
|
+
f.add(a);
|
|
2906
|
+
const r = this.tracker.get(a) ?? xe(o.position.x, o.position.y), c = r.aliveMs + d;
|
|
2907
|
+
if (c >= at || r.kickCount >= nt) {
|
|
2908
|
+
A.push(o), this.tracker.delete(a);
|
|
2762
2909
|
continue;
|
|
2763
2910
|
}
|
|
2764
|
-
const n =
|
|
2765
|
-
let
|
|
2766
|
-
|
|
2767
|
-
const x = s && (i <
|
|
2911
|
+
const n = o.position.x - r.x, h = o.position.y - r.y, l = Math.sqrt(n * n + h * h), t = o.velocity, i = Math.sqrt(t.x * t.x + t.y * t.y), s = o.position.y > T.worldHeight * et;
|
|
2912
|
+
let u = r.anchorY, m = r.anchorAgeMs + d;
|
|
2913
|
+
o.position.y > u + rt && (u = o.position.y, m = 0);
|
|
2914
|
+
const x = s && (i < je && l < qe || m > st) ? r.stuckMs + d : Math.max(0, r.stuckMs - d * 2), P = Math.max(0, r.kickCooldownMs - d);
|
|
2768
2915
|
this.tracker.set(a, {
|
|
2769
|
-
x:
|
|
2770
|
-
y:
|
|
2916
|
+
x: o.position.x,
|
|
2917
|
+
y: o.position.y,
|
|
2771
2918
|
stuckMs: x,
|
|
2772
2919
|
kickCooldownMs: P,
|
|
2773
2920
|
kickCount: r.kickCount,
|
|
2774
|
-
anchorY:
|
|
2921
|
+
anchorY: u,
|
|
2775
2922
|
anchorAgeMs: m,
|
|
2776
|
-
aliveMs:
|
|
2777
|
-
}), x >=
|
|
2778
|
-
ball:
|
|
2923
|
+
aliveMs: c
|
|
2924
|
+
}), x >= _e && P <= 0 && e.push({
|
|
2925
|
+
ball: o,
|
|
2779
2926
|
id: a,
|
|
2780
2927
|
stuckMs: x
|
|
2781
2928
|
});
|
|
2782
2929
|
}
|
|
2783
|
-
this.applyKicks(e,
|
|
2784
|
-
for (const
|
|
2785
|
-
return
|
|
2930
|
+
this.applyKicks(e, T);
|
|
2931
|
+
for (const o of this.tracker.keys()) f.has(o) || this.tracker.delete(o);
|
|
2932
|
+
return A;
|
|
2786
2933
|
}
|
|
2787
2934
|
applyKicks(d, E) {
|
|
2788
2935
|
if (d.length === 0) return;
|
|
2789
|
-
d.sort((
|
|
2790
|
-
const
|
|
2791
|
-
for (let
|
|
2792
|
-
const { ball:
|
|
2793
|
-
if (!
|
|
2794
|
-
const a =
|
|
2795
|
-
|
|
2796
|
-
x: a.x +
|
|
2936
|
+
d.sort((A, f) => Math.abs(f.ball.position.y - A.ball.position.y) > 0.1 ? f.ball.position.y - A.ball.position.y : f.stuckMs - A.stuckMs);
|
|
2937
|
+
const T = Math.min(it, d.length);
|
|
2938
|
+
for (let A = 0; A < T; A++) {
|
|
2939
|
+
const { ball: f, id: e } = d[A], o = this.tracker.get(e);
|
|
2940
|
+
if (!o) continue;
|
|
2941
|
+
const a = f.velocity, r = Math.abs(f.position.x - E.center) / E.halfWidth < ot ? Math.random() < 0.5 ? 1 : -1 : f.position.x < E.center ? 1 : -1, c = r * (0.35 + Math.random() * 0.35) + (Math.random() - 0.5) * 0.25, n = 1.1 + Math.random() * 0.5;
|
|
2942
|
+
O.Body.setVelocity(f, {
|
|
2943
|
+
x: a.x + c,
|
|
2797
2944
|
y: Math.max(a.y + n, n)
|
|
2798
|
-
}),
|
|
2945
|
+
}), O.Body.translate(f, {
|
|
2799
2946
|
x: r * (0.2 + Math.random() * 0.4),
|
|
2800
2947
|
y: 0.25 + Math.random() * 0.35
|
|
2801
2948
|
}), this.tracker.set(e, {
|
|
2802
|
-
...
|
|
2803
|
-
x:
|
|
2804
|
-
y:
|
|
2949
|
+
...o,
|
|
2950
|
+
x: f.position.x,
|
|
2951
|
+
y: f.position.y,
|
|
2805
2952
|
stuckMs: 0,
|
|
2806
|
-
kickCooldownMs:
|
|
2807
|
-
kickCount:
|
|
2953
|
+
kickCooldownMs: tt,
|
|
2954
|
+
kickCount: o.kickCount + 1
|
|
2808
2955
|
});
|
|
2809
2956
|
}
|
|
2810
2957
|
}
|
|
2811
2958
|
};
|
|
2812
|
-
function
|
|
2813
|
-
const E = Math.max(0, Math.min(1, d)) * 0.5,
|
|
2959
|
+
function ut(d) {
|
|
2960
|
+
const E = Math.max(0, Math.min(1, d)) * 0.5, T = E ** 1.5;
|
|
2814
2961
|
return {
|
|
2815
|
-
windStrength: Math.min(
|
|
2816
|
-
collisionNudge:
|
|
2817
|
-
spawnSigmaRatio: E > 0 ? 0.04 -
|
|
2962
|
+
windStrength: Math.min(T * 8e-7, 3e-7),
|
|
2963
|
+
collisionNudge: T * 0.1,
|
|
2964
|
+
spawnSigmaRatio: E > 0 ? 0.04 - T * 0.038 : 0
|
|
2818
2965
|
};
|
|
2819
2966
|
}
|
|
2820
|
-
var
|
|
2821
|
-
function
|
|
2822
|
-
if (!(
|
|
2823
|
-
for (const
|
|
2824
|
-
if (Math.sqrt(
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
x: -
|
|
2967
|
+
var ft = 0.4;
|
|
2968
|
+
function ct(d, E, T) {
|
|
2969
|
+
if (!(T <= 0))
|
|
2970
|
+
for (const A of d) {
|
|
2971
|
+
if (Math.sqrt(A.velocity.x * A.velocity.x + A.velocity.y * A.velocity.y) < ft) continue;
|
|
2972
|
+
const f = A.position.x - E;
|
|
2973
|
+
O.Body.applyForce(A, A.position, {
|
|
2974
|
+
x: -T * f,
|
|
2828
2975
|
y: 0
|
|
2829
2976
|
});
|
|
2830
2977
|
}
|
|
2831
2978
|
}
|
|
2832
|
-
var
|
|
2833
|
-
function
|
|
2979
|
+
var ne = "plinkit-ball";
|
|
2980
|
+
function ht() {
|
|
2834
2981
|
const d = Math.random(), E = Math.random();
|
|
2835
2982
|
return Math.sqrt(-2 * Math.log(d || 1e-15)) * Math.cos(2 * Math.PI * E);
|
|
2836
2983
|
}
|
|
2837
|
-
function
|
|
2838
|
-
const
|
|
2839
|
-
let
|
|
2840
|
-
return E && E > 0 ?
|
|
2841
|
-
label:
|
|
2984
|
+
function gt(d, E) {
|
|
2985
|
+
const T = Math.max(d.radius + 8, d.height * 0.06);
|
|
2986
|
+
let A;
|
|
2987
|
+
return E && E > 0 ? A = ht() * d.width * E : A = (Math.random() - 0.5) * d.width * 0.08, O.Bodies.circle(d.width * 0.5 + A, T, d.radius, {
|
|
2988
|
+
label: ne,
|
|
2842
2989
|
restitution: 0.65,
|
|
2843
2990
|
frictionAir: 1e-3,
|
|
2844
2991
|
friction: 1e-3,
|
|
2845
2992
|
frictionStatic: 0
|
|
2846
2993
|
});
|
|
2847
2994
|
}
|
|
2848
|
-
var
|
|
2995
|
+
var ee = "plinkit-peg", te = "plinkit-guide", oe = "plinkit-wall", dt = 0.22, vt = 4, pt = class {
|
|
2849
2996
|
engine;
|
|
2850
2997
|
config;
|
|
2851
2998
|
pegs = [];
|
|
@@ -2856,30 +3003,49 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
|
|
|
2856
3003
|
pegBaseY = 0;
|
|
2857
3004
|
center = 0;
|
|
2858
3005
|
layoutGeometry = null;
|
|
2859
|
-
antiStuck = new
|
|
3006
|
+
antiStuck = new lt();
|
|
2860
3007
|
dist;
|
|
2861
3008
|
removeCollisionNudge = null;
|
|
3009
|
+
removeCollisionStart = null;
|
|
2862
3010
|
constructor(d) {
|
|
2863
|
-
this.engine =
|
|
3011
|
+
this.engine = O.Engine.create({ gravity: {
|
|
2864
3012
|
x: 0,
|
|
2865
3013
|
y: d.gravityY,
|
|
2866
3014
|
scale: 1e-3
|
|
2867
|
-
} }), this.config = d, this.dist =
|
|
3015
|
+
} }), this.config = d, this.dist = ut(d.houseEdge ?? 0), this.rebuildStaticBodies(d.width, d.height);
|
|
2868
3016
|
const E = this.dist.collisionNudge;
|
|
2869
3017
|
if (E > 0) {
|
|
2870
|
-
const
|
|
2871
|
-
const
|
|
2872
|
-
for (const
|
|
2873
|
-
const a =
|
|
2874
|
-
if (!a || a.plugin.settled || !(
|
|
2875
|
-
const r = (a.position.x -
|
|
2876
|
-
|
|
3018
|
+
const T = (A) => {
|
|
3019
|
+
const f = this.center, e = this.config.width * 0.5;
|
|
3020
|
+
for (const o of A.pairs) {
|
|
3021
|
+
const a = o.bodyA.label === "plinkit-ball" ? o.bodyA : o.bodyB.label === "plinkit-ball" ? o.bodyB : null;
|
|
3022
|
+
if (!a || a.plugin.settled || !(o.bodyA.label === ee || o.bodyB.label === ee || o.bodyA.label === te || o.bodyB.label === te)) continue;
|
|
3023
|
+
const r = (a.position.x - f) / e;
|
|
3024
|
+
O.Body.setVelocity(a, {
|
|
2877
3025
|
x: a.velocity.x - E * r,
|
|
2878
3026
|
y: a.velocity.y
|
|
2879
3027
|
});
|
|
2880
3028
|
}
|
|
2881
3029
|
};
|
|
2882
|
-
|
|
3030
|
+
O.Events.on(this.engine, "collisionEnd", T), this.removeCollisionNudge = () => O.Events.off(this.engine, "collisionEnd", T);
|
|
3031
|
+
}
|
|
3032
|
+
if (d.onCollision) {
|
|
3033
|
+
const T = d.onCollision, A = (f) => {
|
|
3034
|
+
for (const e of f.pairs) {
|
|
3035
|
+
const o = e.bodyA.label === "plinkit-ball" ? e.bodyA : e.bodyB.label === "plinkit-ball" ? e.bodyB : null;
|
|
3036
|
+
if (!o || o.plugin.settled) continue;
|
|
3037
|
+
const a = e.bodyA === o ? e.bodyB.label : e.bodyA.label;
|
|
3038
|
+
let r = null;
|
|
3039
|
+
if (a === ee ? r = "peg" : a === te && (r = "guide"), !r) continue;
|
|
3040
|
+
const c = Math.hypot(o.velocity.x, o.velocity.y);
|
|
3041
|
+
T({
|
|
3042
|
+
ballId: Z(o),
|
|
3043
|
+
target: r,
|
|
3044
|
+
speed: c
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
3048
|
+
O.Events.on(this.engine, "collisionStart", A), this.removeCollisionStart = () => O.Events.off(this.engine, "collisionStart", A);
|
|
2883
3049
|
}
|
|
2884
3050
|
}
|
|
2885
3051
|
resize(d, E) {
|
|
@@ -2889,33 +3055,39 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
|
|
|
2889
3055
|
height: E
|
|
2890
3056
|
}, this.rebuildStaticBodies(d, E);
|
|
2891
3057
|
}
|
|
3058
|
+
setBallCost(d) {
|
|
3059
|
+
this.config = {
|
|
3060
|
+
...this.config,
|
|
3061
|
+
ballCost: d
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
2892
3064
|
spawnBall() {
|
|
2893
|
-
const d =
|
|
3065
|
+
const d = gt({
|
|
2894
3066
|
width: this.config.width,
|
|
2895
3067
|
height: this.config.height,
|
|
2896
3068
|
radius: this.config.ballRadius
|
|
2897
3069
|
}, this.dist.spawnSigmaRatio);
|
|
2898
|
-
d.plugin.ballId = this.nextBallId, this.nextBallId += 1, this.antiStuck.track(
|
|
3070
|
+
d.plugin.ballId = this.nextBallId, d.plugin.wager = this.config.ballCost, this.nextBallId += 1, this.antiStuck.track(Z(d), d.position.x, d.position.y), O.World.add(this.engine.world, d);
|
|
2899
3071
|
}
|
|
2900
3072
|
canSpawnBall() {
|
|
2901
|
-
const d = this.config.height *
|
|
3073
|
+
const d = this.config.height * dt;
|
|
2902
3074
|
let E = 0;
|
|
2903
|
-
const
|
|
2904
|
-
for (const
|
|
2905
|
-
if (!
|
|
3075
|
+
const T = O.Composite.allBodies(this.engine.world).filter((A) => A.label === ne);
|
|
3076
|
+
for (const A of T)
|
|
3077
|
+
if (!A.plugin.settled && A.position.y <= d && (E += 1, E >= vt))
|
|
2906
3078
|
return !1;
|
|
2907
3079
|
return !0;
|
|
2908
3080
|
}
|
|
2909
3081
|
step(d) {
|
|
2910
|
-
|
|
2911
|
-
const E =
|
|
2912
|
-
|
|
2913
|
-
const
|
|
3082
|
+
O.Engine.update(this.engine, d);
|
|
3083
|
+
const E = O.Composite.allBodies(this.engine.world).filter((e) => e.label === ne), T = E.filter((e) => !e.plugin.settled);
|
|
3084
|
+
ct(T, this.center, this.dist.windStrength);
|
|
3085
|
+
const A = this.antiStuck.process(d, T, {
|
|
2914
3086
|
center: this.center,
|
|
2915
3087
|
halfWidth: this.config.width * 0.5,
|
|
2916
3088
|
worldHeight: this.config.height
|
|
2917
|
-
}).map((e) => this.settleBall(e)),
|
|
2918
|
-
return
|
|
3089
|
+
}).map((e) => this.settleBall(e)), f = this.cleanupBalls(E);
|
|
3090
|
+
return A.length > 0 ? [...A, ...f] : f;
|
|
2919
3091
|
}
|
|
2920
3092
|
snapshot() {
|
|
2921
3093
|
const d = this.config.layout.mainPegs.radius;
|
|
@@ -2930,8 +3102,8 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
|
|
|
2930
3102
|
y: E.position.y,
|
|
2931
3103
|
radius: E.circleRadius ?? d
|
|
2932
3104
|
})),
|
|
2933
|
-
balls:
|
|
2934
|
-
id:
|
|
3105
|
+
balls: O.Composite.allBodies(this.engine.world).filter((E) => E.label === ne).map((E) => ({
|
|
3106
|
+
id: Z(E),
|
|
2935
3107
|
x: E.position.x,
|
|
2936
3108
|
y: E.position.y,
|
|
2937
3109
|
radius: E.circleRadius ?? this.config.ballRadius
|
|
@@ -2941,79 +3113,79 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
|
|
|
2941
3113
|
};
|
|
2942
3114
|
}
|
|
2943
3115
|
destroy() {
|
|
2944
|
-
this.removeCollisionNudge?.(),
|
|
3116
|
+
this.removeCollisionNudge?.(), this.removeCollisionStart?.(), O.World.clear(this.engine.world, !1), O.Engine.clear(this.engine);
|
|
2945
3117
|
}
|
|
2946
3118
|
cleanupBalls(d) {
|
|
2947
|
-
const E = [],
|
|
2948
|
-
for (const
|
|
2949
|
-
if (
|
|
2950
|
-
this.antiStuck.untrack(
|
|
3119
|
+
const E = [], T = this.config.height + this.config.ballRadius, A = this.getBucketTop();
|
|
3120
|
+
for (const f of d) {
|
|
3121
|
+
if (f.position.y > T) {
|
|
3122
|
+
this.antiStuck.untrack(Z(f)), O.World.remove(this.engine.world, f);
|
|
2951
3123
|
continue;
|
|
2952
3124
|
}
|
|
2953
|
-
if (!
|
|
2954
|
-
E.push(this.settleBall(
|
|
3125
|
+
if (!f.plugin.settled && f.position.y >= A) {
|
|
3126
|
+
E.push(this.settleBall(f));
|
|
2955
3127
|
continue;
|
|
2956
3128
|
}
|
|
2957
|
-
const e =
|
|
2958
|
-
!
|
|
3129
|
+
const e = f.circleRadius ?? this.config.ballRadius, o = this.config.height - e - 1;
|
|
3130
|
+
!f.plugin.settled && f.position.y >= o && E.push(this.settleBall(f));
|
|
2959
3131
|
}
|
|
2960
3132
|
return E;
|
|
2961
3133
|
}
|
|
2962
3134
|
rebuildStaticBodies(d, E) {
|
|
2963
|
-
this.antiStuck.clear(), this.pegs.length > 0 && (
|
|
3135
|
+
this.antiStuck.clear(), this.pegs.length > 0 && (O.World.remove(this.engine.world, this.pegs), this.pegs = []), this.guidePegs.length > 0 && (O.World.remove(this.engine.world, this.guidePegs), this.guidePegs = []), this.walls && (O.World.remove(this.engine.world, [
|
|
2964
3136
|
this.walls.leftWall,
|
|
2965
3137
|
this.walls.rightWall,
|
|
2966
3138
|
this.walls.floor
|
|
2967
3139
|
]), this.walls = null), this.center = d * 0.5;
|
|
2968
|
-
const
|
|
2969
|
-
...
|
|
3140
|
+
const T = Math.max(18, d * 0.02), A = d / this.config.multipliers.length, f = this.config.layout.mainPegs, e = He({
|
|
3141
|
+
...f,
|
|
2970
3142
|
width: d,
|
|
2971
3143
|
height: E
|
|
2972
3144
|
});
|
|
2973
3145
|
this.layoutGeometry = e;
|
|
2974
|
-
const
|
|
2975
|
-
this.pegs =
|
|
3146
|
+
const o = f.radius, a = this.config.layout.edgeGuides.radius;
|
|
3147
|
+
this.pegs = Ve(e, o).map((t) => O.Bodies.circle(t.x, t.y, t.radius, {
|
|
2976
3148
|
isStatic: !0,
|
|
2977
|
-
label:
|
|
3149
|
+
label: ee,
|
|
2978
3150
|
restitution: 0.3
|
|
2979
3151
|
})), this.pegBaseY = this.pegs.reduce((t, i) => Math.max(t, i.position.y), 0);
|
|
2980
|
-
const r = this.getBucketTop(),
|
|
3152
|
+
const r = this.getBucketTop(), c = O.Bodies.rectangle(-T * 0.5, E * 0.5, T, E * 2, {
|
|
2981
3153
|
isStatic: !0,
|
|
2982
|
-
label:
|
|
3154
|
+
label: oe,
|
|
2983
3155
|
restitution: 0.4
|
|
2984
|
-
}), n =
|
|
3156
|
+
}), n = O.Bodies.rectangle(d + T * 0.5, E * 0.5, T, E * 2, {
|
|
2985
3157
|
isStatic: !0,
|
|
2986
|
-
label:
|
|
3158
|
+
label: oe,
|
|
2987
3159
|
restitution: 0.4
|
|
2988
|
-
}),
|
|
3160
|
+
}), h = O.Bodies.rectangle(d * 0.5, E + T * 0.5, d, T, {
|
|
2989
3161
|
isStatic: !0,
|
|
2990
3162
|
isSensor: !0,
|
|
2991
|
-
label:
|
|
3163
|
+
label: oe
|
|
2992
3164
|
});
|
|
2993
3165
|
this.walls = {
|
|
2994
|
-
leftWall:
|
|
3166
|
+
leftWall: c,
|
|
2995
3167
|
rightWall: n,
|
|
2996
|
-
floor:
|
|
2997
|
-
},
|
|
2998
|
-
|
|
3168
|
+
floor: h
|
|
3169
|
+
}, O.World.add(this.engine.world, [
|
|
3170
|
+
c,
|
|
2999
3171
|
n,
|
|
3000
|
-
|
|
3001
|
-
]), this.guidePegs =
|
|
3172
|
+
h
|
|
3173
|
+
]), this.guidePegs = Ne(e, a, {
|
|
3002
3174
|
spread: this.config.layout.edgeGuides.spread,
|
|
3003
3175
|
yOffset: this.config.layout.edgeGuides.yOffset
|
|
3004
|
-
}).map((t) =>
|
|
3176
|
+
}).map((t) => O.Bodies.circle(t.x, t.y, t.radius, {
|
|
3005
3177
|
isStatic: !0,
|
|
3006
|
-
label:
|
|
3178
|
+
label: te,
|
|
3007
3179
|
restitution: 0.3
|
|
3008
|
-
})),
|
|
3009
|
-
const
|
|
3180
|
+
})), O.World.add(this.engine.world, this.pegs), O.World.add(this.engine.world, this.guidePegs);
|
|
3181
|
+
const l = E - r;
|
|
3010
3182
|
this.buckets = this.config.multipliers.map((t, i) => ({
|
|
3011
3183
|
index: i,
|
|
3012
3184
|
multiplier: t,
|
|
3013
|
-
x:
|
|
3185
|
+
x: A * i,
|
|
3014
3186
|
y: r,
|
|
3015
|
-
width:
|
|
3016
|
-
height:
|
|
3187
|
+
width: A,
|
|
3188
|
+
height: l
|
|
3017
3189
|
}));
|
|
3018
3190
|
}
|
|
3019
3191
|
getWallRects() {
|
|
@@ -3033,17 +3205,17 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
|
|
|
3033
3205
|
return this.pegBaseY > 0 ? Math.min(this.config.height - 6, this.pegBaseY + d) : this.config.height * 0.85;
|
|
3034
3206
|
}
|
|
3035
3207
|
settleBall(d) {
|
|
3036
|
-
d.plugin.settled = !0,
|
|
3037
|
-
const E = this.layoutGeometry,
|
|
3208
|
+
d.plugin.settled = !0, O.Body.set(d, "isSensor", !0);
|
|
3209
|
+
const E = this.layoutGeometry, T = this.config.layout.mainPegs, A = E?.sidePadding ?? T.radius + T.sidePaddingPx, f = E?.baseSpacing ?? (this.config.width - A * 2) / Math.max(T.bottomPegCount - 1, 1), e = Je(d.position.x, A, f, this.config.multipliers.length), o = this.config.multipliers[e] ?? 0, a = typeof d.plugin.wager == "number" ? d.plugin.wager : this.config.ballCost;
|
|
3038
3210
|
return {
|
|
3039
|
-
ballId:
|
|
3211
|
+
ballId: Z(d),
|
|
3040
3212
|
bucketIndex: e,
|
|
3041
|
-
multiplier:
|
|
3042
|
-
wager:
|
|
3043
|
-
payout:
|
|
3213
|
+
multiplier: o,
|
|
3214
|
+
wager: a,
|
|
3215
|
+
payout: a * o
|
|
3044
3216
|
};
|
|
3045
3217
|
}
|
|
3046
|
-
},
|
|
3218
|
+
}, mt = `
|
|
3047
3219
|
precision highp float;
|
|
3048
3220
|
in vec2 a_position;
|
|
3049
3221
|
uniform vec2 u_resolution;
|
|
@@ -3059,7 +3231,7 @@ void main() {
|
|
|
3059
3231
|
v_local = a_position;
|
|
3060
3232
|
v_uv = a_position * 0.5 + 0.5;
|
|
3061
3233
|
}
|
|
3062
|
-
`,
|
|
3234
|
+
`, xt = `
|
|
3063
3235
|
precision highp float;
|
|
3064
3236
|
uniform vec4 u_color;
|
|
3065
3237
|
uniform float u_shapeMode;
|
|
@@ -3086,7 +3258,7 @@ void main() {
|
|
|
3086
3258
|
outColor = vec4(u_color.rgb, u_color.a * a);
|
|
3087
3259
|
}
|
|
3088
3260
|
}
|
|
3089
|
-
`,
|
|
3261
|
+
`, yt = class {
|
|
3090
3262
|
canvas;
|
|
3091
3263
|
gl;
|
|
3092
3264
|
program;
|
|
@@ -3107,17 +3279,17 @@ void main() {
|
|
|
3107
3279
|
ballTextureReady = !1;
|
|
3108
3280
|
constructor(d, E) {
|
|
3109
3281
|
this.canvas = d;
|
|
3110
|
-
const
|
|
3282
|
+
const T = d.getContext("webgl2", {
|
|
3111
3283
|
antialias: !0,
|
|
3112
3284
|
alpha: !0
|
|
3113
3285
|
});
|
|
3114
|
-
if (!
|
|
3115
|
-
this.gl =
|
|
3116
|
-
const
|
|
3117
|
-
this.program =
|
|
3118
|
-
const e = this.gl.getAttribLocation(this.program, "a_position"),
|
|
3119
|
-
if (e < 0 || !
|
|
3120
|
-
this.positionLocation = e, this.resolutionLocation =
|
|
3286
|
+
if (!T) throw new Error("WebGL2 is not supported by this browser");
|
|
3287
|
+
this.gl = T;
|
|
3288
|
+
const A = ye(this.gl, this.gl.VERTEX_SHADER, mt), f = ye(this.gl, this.gl.FRAGMENT_SHADER, xt);
|
|
3289
|
+
this.program = Pt(this.gl, A, f);
|
|
3290
|
+
const e = this.gl.getAttribLocation(this.program, "a_position"), o = this.gl.getUniformLocation(this.program, "u_resolution"), a = this.gl.getUniformLocation(this.program, "u_center"), r = this.gl.getUniformLocation(this.program, "u_size"), c = this.gl.getUniformLocation(this.program, "u_color"), n = this.gl.getUniformLocation(this.program, "u_shapeMode"), h = this.gl.getUniformLocation(this.program, "u_useTexture"), l = this.gl.getUniformLocation(this.program, "u_texture");
|
|
3291
|
+
if (e < 0 || !o || !a || !r || !c || !n || !h || !l) throw new Error("Unable to initialize WebGL program locations");
|
|
3292
|
+
this.positionLocation = e, this.resolutionLocation = o, this.centerLocation = a, this.sizeLocation = r, this.colorLocation = c, this.shapeModeLocation = n, this.useTextureLocation = h, this.textureLocation = l, this.gl.useProgram(this.program), this.gl.uniform1i(this.textureLocation, 0);
|
|
3121
3293
|
const t = this.gl.createBuffer();
|
|
3122
3294
|
if (!t) throw new Error("Unable to create WebGL buffer");
|
|
3123
3295
|
this.positionBuffer = t, this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
|
|
@@ -3137,79 +3309,79 @@ void main() {
|
|
|
3137
3309
|
const i = E?.appearance;
|
|
3138
3310
|
i?.pegTextureUrl && this.startTextureLoad(i.pegTextureUrl, i.textureCrossOrigin, "peg"), i?.ballTextureUrl && this.startTextureLoad(i.ballTextureUrl, i.textureCrossOrigin, "ball");
|
|
3139
3311
|
}
|
|
3140
|
-
resize(d, E,
|
|
3141
|
-
this.scale =
|
|
3312
|
+
resize(d, E, T, A = 1) {
|
|
3313
|
+
this.scale = T * A, this.canvas.width = Math.floor(d * T), this.canvas.height = Math.floor(E * T), this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
3142
3314
|
}
|
|
3143
3315
|
render(d) {
|
|
3144
3316
|
this.gl.clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT), this.gl.useProgram(this.program), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer), this.gl.enableVertexAttribArray(this.positionLocation), this.gl.vertexAttribPointer(this.positionLocation, 2, this.gl.FLOAT, !1, 0, 0), this.gl.uniform2f(this.resolutionLocation, this.canvas.width, this.canvas.height), this.gl.uniform1i(this.textureLocation, 0);
|
|
3145
|
-
for (const E of d.walls) this.drawRect(E,
|
|
3146
|
-
for (const E of d.pegs) this.drawCircle(E.x, E.y, E.radius,
|
|
3147
|
-
for (const E of d.guidePegs) this.drawCircle(E.x, E.y, E.radius,
|
|
3148
|
-
for (const E of d.balls) this.drawCircle(E.x, E.y, E.radius,
|
|
3317
|
+
for (const E of d.walls) this.drawRect(E, ie(54, 68, 102));
|
|
3318
|
+
for (const E of d.pegs) this.drawCircle(E.x, E.y, E.radius, ie(141, 226, 255), "peg");
|
|
3319
|
+
for (const E of d.guidePegs) this.drawCircle(E.x, E.y, E.radius, ie(255, 90, 120), "peg");
|
|
3320
|
+
for (const E of d.balls) this.drawCircle(E.x, E.y, E.radius, ie(250, 201, 95), "ball");
|
|
3149
3321
|
}
|
|
3150
3322
|
destroy() {
|
|
3151
3323
|
this.destroyed = !0, this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.pegTexture && (this.gl.deleteTexture(this.pegTexture), this.pegTexture = null), this.ballTexture && (this.gl.deleteTexture(this.ballTexture), this.ballTexture = null), this.pegTextureReady = !1, this.ballTextureReady = !1, this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteProgram(this.program);
|
|
3152
3324
|
}
|
|
3153
|
-
startTextureLoad(d, E,
|
|
3154
|
-
|
|
3325
|
+
startTextureLoad(d, E, T) {
|
|
3326
|
+
wt(d, E).then((A) => {
|
|
3155
3327
|
if (this.destroyed) return;
|
|
3156
|
-
const
|
|
3328
|
+
const f = St(this.gl, A);
|
|
3157
3329
|
if (this.destroyed) {
|
|
3158
|
-
this.gl.deleteTexture(
|
|
3330
|
+
this.gl.deleteTexture(f);
|
|
3159
3331
|
return;
|
|
3160
3332
|
}
|
|
3161
|
-
|
|
3333
|
+
T === "peg" ? (this.pegTexture && this.gl.deleteTexture(this.pegTexture), this.pegTexture = f, this.pegTextureReady = !0) : (this.ballTexture && this.gl.deleteTexture(this.ballTexture), this.ballTexture = f, this.ballTextureReady = !0);
|
|
3162
3334
|
}).catch(() => {
|
|
3163
3335
|
});
|
|
3164
3336
|
}
|
|
3165
3337
|
drawRect(d, E) {
|
|
3166
3338
|
this.gl.uniform2f(this.centerLocation, d.x * this.scale, d.y * this.scale), this.gl.uniform2f(this.sizeLocation, d.width * this.scale * 0.5, d.height * this.scale * 0.5), this.gl.uniform4f(this.colorLocation, E.r, E.g, E.b, E.a), this.gl.uniform1f(this.shapeModeLocation, 0), this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
|
|
3167
3339
|
}
|
|
3168
|
-
drawCircle(d, E,
|
|
3169
|
-
this.gl.uniform2f(this.centerLocation, d * this.scale, E * this.scale), this.gl.uniform2f(this.sizeLocation,
|
|
3170
|
-
const e =
|
|
3171
|
-
e &&
|
|
3340
|
+
drawCircle(d, E, T, A, f) {
|
|
3341
|
+
this.gl.uniform2f(this.centerLocation, d * this.scale, E * this.scale), this.gl.uniform2f(this.sizeLocation, T * this.scale, T * this.scale), this.gl.uniform4f(this.colorLocation, A.r, A.g, A.b, A.a), this.gl.uniform1f(this.shapeModeLocation, 1);
|
|
3342
|
+
const e = f === "peg" ? this.pegTexture : this.ballTexture, o = f === "peg" ? this.pegTextureReady : this.ballTextureReady;
|
|
3343
|
+
e && o ? (this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, e), this.gl.uniform1f(this.useTextureLocation, 1)) : this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
|
|
3172
3344
|
}
|
|
3173
3345
|
};
|
|
3174
|
-
function
|
|
3346
|
+
function ie(d, E, T, A = 1) {
|
|
3175
3347
|
return {
|
|
3176
3348
|
r: d / 255,
|
|
3177
3349
|
g: E / 255,
|
|
3178
|
-
b:
|
|
3179
|
-
a:
|
|
3350
|
+
b: T / 255,
|
|
3351
|
+
a: A
|
|
3180
3352
|
};
|
|
3181
3353
|
}
|
|
3182
|
-
function
|
|
3183
|
-
const
|
|
3184
|
-
if (!
|
|
3185
|
-
return d.bindTexture(d.TEXTURE_2D,
|
|
3354
|
+
function St(d, E) {
|
|
3355
|
+
const T = d.createTexture();
|
|
3356
|
+
if (!T) throw new Error("Unable to create WebGL texture");
|
|
3357
|
+
return d.bindTexture(d.TEXTURE_2D, T), d.texImage2D(d.TEXTURE_2D, 0, d.RGBA, d.RGBA, d.UNSIGNED_BYTE, E), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MIN_FILTER, d.LINEAR), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MAG_FILTER, d.LINEAR), d.bindTexture(d.TEXTURE_2D, null), T;
|
|
3186
3358
|
}
|
|
3187
|
-
function
|
|
3188
|
-
return new Promise((
|
|
3189
|
-
const
|
|
3190
|
-
typeof E == "string" && E.length > 0 && (
|
|
3359
|
+
function wt(d, E) {
|
|
3360
|
+
return new Promise((T, A) => {
|
|
3361
|
+
const f = new Image();
|
|
3362
|
+
typeof E == "string" && E.length > 0 && (f.crossOrigin = E), f.onload = () => T(f), f.onerror = () => A(/* @__PURE__ */ new Error(`Failed to load image: ${d}`)), f.src = d;
|
|
3191
3363
|
});
|
|
3192
3364
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const
|
|
3195
|
-
if (!
|
|
3196
|
-
if (d.shaderSource(
|
|
3197
|
-
${
|
|
3198
|
-
const
|
|
3199
|
-
throw d.deleteShader(
|
|
3200
|
-
}
|
|
3201
|
-
return
|
|
3365
|
+
function ye(d, E, T) {
|
|
3366
|
+
const A = d.createShader(E);
|
|
3367
|
+
if (!A) throw new Error("Unable to create shader");
|
|
3368
|
+
if (d.shaderSource(A, `#version 300 es
|
|
3369
|
+
${T}`), d.compileShader(A), !d.getShaderParameter(A, d.COMPILE_STATUS)) {
|
|
3370
|
+
const f = d.getShaderInfoLog(A);
|
|
3371
|
+
throw d.deleteShader(A), new Error(`Shader compile error: ${f ?? "unknown"}`);
|
|
3372
|
+
}
|
|
3373
|
+
return A;
|
|
3202
3374
|
}
|
|
3203
|
-
function
|
|
3204
|
-
const
|
|
3205
|
-
if (!
|
|
3206
|
-
if (d.attachShader(
|
|
3207
|
-
const
|
|
3208
|
-
throw d.deleteProgram(
|
|
3209
|
-
}
|
|
3210
|
-
return d.deleteShader(E), d.deleteShader(
|
|
3375
|
+
function Pt(d, E, T) {
|
|
3376
|
+
const A = d.createProgram();
|
|
3377
|
+
if (!A) throw new Error("Unable to create program");
|
|
3378
|
+
if (d.attachShader(A, E), d.attachShader(A, T), d.linkProgram(A), !d.getProgramParameter(A, d.LINK_STATUS)) {
|
|
3379
|
+
const f = d.getProgramInfoLog(A);
|
|
3380
|
+
throw d.deleteProgram(A), new Error(`Program link error: ${f ?? "unknown"}`);
|
|
3381
|
+
}
|
|
3382
|
+
return d.deleteShader(E), d.deleteShader(T), A;
|
|
3211
3383
|
}
|
|
3212
|
-
var
|
|
3384
|
+
var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
|
|
3213
3385
|
canvas;
|
|
3214
3386
|
viewport;
|
|
3215
3387
|
renderer;
|
|
@@ -3228,41 +3400,49 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
|
|
|
3228
3400
|
showGuidePegs;
|
|
3229
3401
|
balance;
|
|
3230
3402
|
lastSpawnAtMs = -1 / 0;
|
|
3403
|
+
audio;
|
|
3231
3404
|
constructor(d) {
|
|
3232
3405
|
this.canvas = d.canvas, this.viewport = d.viewport, this.width = 1, this.height = 1, this.callbacks = {
|
|
3233
3406
|
onBalanceChange: d.onBalanceChange,
|
|
3234
3407
|
onBallSettled: d.onBallSettled
|
|
3235
|
-
}, this.ballCost = d.ballCost, this.showGuidePegs = d.showGuidePegs, this.balance = d.initialBalance, this.onDprChange = () => this.listenDpr()
|
|
3236
|
-
|
|
3408
|
+
}, this.ballCost = d.ballCost, this.showGuidePegs = d.showGuidePegs, this.balance = d.initialBalance, this.onDprChange = () => this.listenDpr(), this.audio = d.audio ? new Fe({
|
|
3409
|
+
pegHitUrl: d.audio.pegHitUrl,
|
|
3410
|
+
bucketHitUrl: d.audio.bucketHitUrl,
|
|
3411
|
+
uiTapUrl: d.audio.uiTapUrl,
|
|
3412
|
+
masterVolume: d.audio.masterVolume ?? 1,
|
|
3413
|
+
muted: d.audio.muted ?? !1
|
|
3414
|
+
}) : null;
|
|
3415
|
+
const E = ze({
|
|
3237
3416
|
mainPegs: d.layout.mainPegs,
|
|
3238
3417
|
ballRadius: d.ballRadius,
|
|
3239
3418
|
heightPolicy: d.viewport.heightPolicy
|
|
3240
|
-
}),
|
|
3419
|
+
}), T = {
|
|
3241
3420
|
...d.layout,
|
|
3242
3421
|
mainPegs: E.resolvedMainPegs
|
|
3243
3422
|
};
|
|
3244
|
-
this.worldHeight = E.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new
|
|
3423
|
+
this.worldHeight = E.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new yt(this.canvas, { appearance: d.appearance }), this.world = new pt({
|
|
3245
3424
|
width: 600,
|
|
3246
3425
|
height: this.worldHeight,
|
|
3247
3426
|
gravityY: d.gravityY,
|
|
3248
|
-
layout:
|
|
3427
|
+
layout: T,
|
|
3249
3428
|
ballRadius: d.ballRadius,
|
|
3250
3429
|
multipliers: d.multipliers,
|
|
3251
3430
|
ballCost: this.ballCost,
|
|
3252
|
-
houseEdge: d.houseEdge
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3431
|
+
houseEdge: d.houseEdge,
|
|
3432
|
+
onCollision: this.audio ? (f) => this.handleCollision(f) : void 0
|
|
3433
|
+
}), this.resize(), this.loop = new Oe((f) => this.frame(f)), this.loop.start();
|
|
3434
|
+
const A = this.canvas.parentElement;
|
|
3435
|
+
if (!A) throw new Error("Canvas must have a parent element for viewport sizing");
|
|
3436
|
+
this.resizeObserver = new ResizeObserver((f) => {
|
|
3437
|
+
const e = f[0];
|
|
3258
3438
|
if (!e) return;
|
|
3259
|
-
const
|
|
3439
|
+
const o = e.contentBoxSize?.[0]?.inlineSize, a = o != null && o > 0 ? o : A.getBoundingClientRect().width;
|
|
3260
3440
|
this.syncViewport(a);
|
|
3261
|
-
}), this.resizeObserver.observe(
|
|
3441
|
+
}), this.resizeObserver.observe(A), this.listenDpr(), this.emitBalanceChange();
|
|
3262
3442
|
}
|
|
3263
3443
|
spawnBall() {
|
|
3264
3444
|
const d = performance.now();
|
|
3265
|
-
return d - this.lastSpawnAtMs <
|
|
3445
|
+
return d - this.lastSpawnAtMs < Tt ? {
|
|
3266
3446
|
ok: !1,
|
|
3267
3447
|
reason: "SPAWN_COOLDOWN",
|
|
3268
3448
|
state: this.getStateSnapshot()
|
|
@@ -3270,7 +3450,7 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
|
|
|
3270
3450
|
ok: !1,
|
|
3271
3451
|
reason: "INSUFFICIENT_BALANCE",
|
|
3272
3452
|
state: this.getStateSnapshot()
|
|
3273
|
-
} : (this.balance -= this.ballCost, this.lastSpawnAtMs = d, this.emitBalanceChange(), this.world.spawnBall(), {
|
|
3453
|
+
} : (this.balance -= this.ballCost, this.lastSpawnAtMs = d, this.emitBalanceChange(), this.audio?.resume(), this.world.spawnBall(), {
|
|
3274
3454
|
ok: !0,
|
|
3275
3455
|
state: this.getStateSnapshot()
|
|
3276
3456
|
}) : {
|
|
@@ -3284,27 +3464,46 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
|
|
|
3284
3464
|
d && this.syncViewport(d.getBoundingClientRect().width);
|
|
3285
3465
|
}
|
|
3286
3466
|
destroy() {
|
|
3287
|
-
this.loop.stop(), this.resizeObserver.disconnect(), this.dprQuery?.removeEventListener("change", this.onDprChange), this.dprQuery = null, this.world.destroy(), this.renderer.destroy();
|
|
3467
|
+
this.loop.stop(), this.resizeObserver.disconnect(), this.dprQuery?.removeEventListener("change", this.onDprChange), this.dprQuery = null, this.world.destroy(), this.renderer.destroy(), this.audio?.destroy();
|
|
3288
3468
|
}
|
|
3289
3469
|
getState() {
|
|
3290
3470
|
return this.getStateSnapshot();
|
|
3291
3471
|
}
|
|
3472
|
+
setBallCost(d) {
|
|
3473
|
+
if (!Number.isFinite(d) || d < 0) throw new TypeError(`Plinkit.setBallCost: expected a non-negative finite number, got ${d}`);
|
|
3474
|
+
this.ballCost !== d && (this.ballCost = d, this.world.setBallCost(d), this.emitBalanceChange());
|
|
3475
|
+
}
|
|
3476
|
+
setMuted(d) {
|
|
3477
|
+
this.audio?.setMuted(d);
|
|
3478
|
+
}
|
|
3479
|
+
isMuted() {
|
|
3480
|
+
return this.audio?.isMuted() ?? !0;
|
|
3481
|
+
}
|
|
3482
|
+
setVolume(d) {
|
|
3483
|
+
this.audio?.setVolume(d);
|
|
3484
|
+
}
|
|
3485
|
+
playUiTap() {
|
|
3486
|
+
this.audio?.playUiTap();
|
|
3487
|
+
}
|
|
3488
|
+
handleCollision(d) {
|
|
3489
|
+
this.audio?.playPegHit(d.ballId, d.speed);
|
|
3490
|
+
}
|
|
3292
3491
|
frame(d) {
|
|
3293
3492
|
if (this.lastFrameTime === 0) {
|
|
3294
3493
|
this.lastFrameTime = d, this.renderSnapshot();
|
|
3295
3494
|
return;
|
|
3296
3495
|
}
|
|
3297
|
-
const E = Math.min(
|
|
3496
|
+
const E = Math.min(Ct, d - this.lastFrameTime);
|
|
3298
3497
|
this.lastFrameTime = d, this.accumulatorMs += E;
|
|
3299
|
-
let
|
|
3300
|
-
for (; this.accumulatorMs >=
|
|
3301
|
-
const
|
|
3302
|
-
for (const
|
|
3303
|
-
this.balance +=
|
|
3498
|
+
let T = 0;
|
|
3499
|
+
for (; this.accumulatorMs >= le && T < Mt; ) {
|
|
3500
|
+
const A = this.world.step(le);
|
|
3501
|
+
for (const f of A) {
|
|
3502
|
+
this.balance += f.payout;
|
|
3304
3503
|
const e = this.getStateSnapshot();
|
|
3305
|
-
this.callbacks.onBallSettled?.(
|
|
3504
|
+
this.callbacks.onBallSettled?.(f, e), this.callbacks.onBalanceChange?.(e), this.audio?.playBucketHit();
|
|
3306
3505
|
}
|
|
3307
|
-
this.accumulatorMs -=
|
|
3506
|
+
this.accumulatorMs -= le, T += 1;
|
|
3308
3507
|
}
|
|
3309
3508
|
this.renderSnapshot();
|
|
3310
3509
|
}
|
|
@@ -3316,14 +3515,14 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
|
|
|
3316
3515
|
this.callbacks.onBalanceChange?.(this.getStateSnapshot());
|
|
3317
3516
|
}
|
|
3318
3517
|
syncViewport(d) {
|
|
3319
|
-
const E =
|
|
3518
|
+
const E = Xe({
|
|
3320
3519
|
parentWidthPx: d,
|
|
3321
3520
|
viewport: this.viewport,
|
|
3322
3521
|
worldHeight: this.worldHeight
|
|
3323
3522
|
});
|
|
3324
3523
|
this.width = Math.max(1, E.displayWidth), this.height = Math.max(1, E.displayHeight), this.canvas.style.width = `${this.width}px`, this.canvas.style.height = `${this.height}px`;
|
|
3325
|
-
const
|
|
3326
|
-
this.renderer.resize(this.width, this.height,
|
|
3524
|
+
const T = Math.min(window.devicePixelRatio || 1, this.viewport.dprCap);
|
|
3525
|
+
this.renderer.resize(this.width, this.height, T, E.worldScale);
|
|
3327
3526
|
}
|
|
3328
3527
|
listenDpr() {
|
|
3329
3528
|
this.dprQuery?.removeEventListener("change", this.onDprChange);
|
|
@@ -3338,5 +3537,5 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
|
|
|
3338
3537
|
}
|
|
3339
3538
|
};
|
|
3340
3539
|
export {
|
|
3341
|
-
|
|
3540
|
+
Bt as Plinkit
|
|
3342
3541
|
};
|