q5 2.6.1 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/q5.d.ts +697 -564
- package/q5.js +49 -26
- package/q5.min.js +2 -2
- package/src/q5-2d-drawing.js +1 -1
- package/src/q5-2d-image.js +2 -1
- package/src/q5-ai.js +2 -3
- package/src/q5-canvas.js +7 -0
- package/src/q5-core.js +34 -18
- package/src/q5-input.js +3 -3
package/src/q5-core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* q5.js
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.7
|
|
4
4
|
* @author quinton-ashley, Tezumie, and LingDong-
|
|
5
5
|
* @license LGPL-3.0
|
|
6
6
|
* @class Q5
|
|
@@ -89,7 +89,13 @@ function Q5(scope, parent, renderer) {
|
|
|
89
89
|
$.resetMatrix();
|
|
90
90
|
if ($._beginRender) $._beginRender();
|
|
91
91
|
for (let m of Q5.methods.pre) m.call($);
|
|
92
|
-
|
|
92
|
+
try {
|
|
93
|
+
$.draw();
|
|
94
|
+
} catch (e) {
|
|
95
|
+
if (!Q5.disableFriendlyErrors && $._askAI) $._askAI(e);
|
|
96
|
+
if (!Q5.errorTolerant) $.noLoop();
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
93
99
|
for (let m of Q5.methods.post) m.call($);
|
|
94
100
|
if ($._render) $._render();
|
|
95
101
|
if ($._finishRender) $._finishRender();
|
|
@@ -128,7 +134,7 @@ function Q5(scope, parent, renderer) {
|
|
|
128
134
|
}
|
|
129
135
|
return $._frameRate;
|
|
130
136
|
};
|
|
131
|
-
$.getTargetFrameRate = () => $._targetFrameRate;
|
|
137
|
+
$.getTargetFrameRate = () => $._targetFrameRate || 60;
|
|
132
138
|
$.getFPS = () => $._fps;
|
|
133
139
|
|
|
134
140
|
$.Element = function (a) {
|
|
@@ -196,10 +202,16 @@ function Q5(scope, parent, renderer) {
|
|
|
196
202
|
let t = globalScope || $;
|
|
197
203
|
$._isTouchAware = t.touchStarted || t.touchMoved || t.mouseReleased;
|
|
198
204
|
let preloadDefined = t.preload;
|
|
205
|
+
if ($._isGlobal) {
|
|
206
|
+
$.preload = t.preload;
|
|
207
|
+
$.setup = t.setup;
|
|
208
|
+
$.draw = t.draw;
|
|
209
|
+
} else {
|
|
210
|
+
$.preload ??= () => {};
|
|
211
|
+
$.setup ??= () => {};
|
|
212
|
+
$.draw ??= () => {};
|
|
213
|
+
}
|
|
199
214
|
let userFns = [
|
|
200
|
-
'setup',
|
|
201
|
-
'draw',
|
|
202
|
-
'preload',
|
|
203
215
|
'mouseMoved',
|
|
204
216
|
'mousePressed',
|
|
205
217
|
'mouseReleased',
|
|
@@ -220,15 +232,13 @@ function Q5(scope, parent, renderer) {
|
|
|
220
232
|
try {
|
|
221
233
|
return t[k]();
|
|
222
234
|
} catch (e) {
|
|
223
|
-
if ($.
|
|
235
|
+
if ($._askAI) $._askAI(e);
|
|
224
236
|
throw e;
|
|
225
237
|
}
|
|
226
238
|
};
|
|
227
239
|
}
|
|
228
240
|
}
|
|
229
241
|
|
|
230
|
-
if (!($.setup || $.draw)) return;
|
|
231
|
-
|
|
232
242
|
async function _start() {
|
|
233
243
|
$._startDone = true;
|
|
234
244
|
if ($._preloadCount > 0) return raf(_start);
|
|
@@ -236,19 +246,25 @@ function Q5(scope, parent, renderer) {
|
|
|
236
246
|
await $.setup();
|
|
237
247
|
$._setupDone = true;
|
|
238
248
|
if ($.frameCount) return;
|
|
239
|
-
if ($.ctx === null) $.createCanvas(
|
|
249
|
+
if ($.ctx === null) $.createCanvas(200, 200);
|
|
240
250
|
if ($.ctx) $.resetMatrix();
|
|
241
251
|
raf($._draw);
|
|
242
252
|
}
|
|
243
253
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} else {
|
|
248
|
-
t.preload = $.preload = () => {
|
|
254
|
+
function _preStart() {
|
|
255
|
+
try {
|
|
256
|
+
$.preload();
|
|
249
257
|
if (!$._startDone) _start();
|
|
250
|
-
}
|
|
251
|
-
|
|
258
|
+
} catch (e) {
|
|
259
|
+
if ($._askAI) $._askAI(e);
|
|
260
|
+
throw e;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (preloadDefined || (arguments.length && scope != 'instance' && renderer != 'webgpu')) {
|
|
265
|
+
_preStart();
|
|
266
|
+
} else {
|
|
267
|
+
setTimeout(_preStart, 32);
|
|
252
268
|
}
|
|
253
269
|
}
|
|
254
270
|
|
|
@@ -259,7 +275,7 @@ Q5._nodejs = typeof process == 'object';
|
|
|
259
275
|
|
|
260
276
|
Q5._instanceCount = 0;
|
|
261
277
|
Q5._friendlyError = (msg, func) => {
|
|
262
|
-
console.error(func + ': ' + msg);
|
|
278
|
+
if (!Q5.disableFriendlyErrors) console.error(func + ': ' + msg);
|
|
263
279
|
};
|
|
264
280
|
Q5._validateParameters = () => true;
|
|
265
281
|
|
package/src/q5-input.js
CHANGED
|
@@ -6,11 +6,11 @@ Q5.modules.input = ($, q) => {
|
|
|
6
6
|
$.pmouseX = 0;
|
|
7
7
|
$.pmouseY = 0;
|
|
8
8
|
$.touches = [];
|
|
9
|
-
$.mouseButton =
|
|
9
|
+
$.mouseButton = '';
|
|
10
10
|
$.keyIsPressed = false;
|
|
11
11
|
$.mouseIsPressed = false;
|
|
12
|
-
$.key =
|
|
13
|
-
$.keyCode =
|
|
12
|
+
$.key = '';
|
|
13
|
+
$.keyCode = 0;
|
|
14
14
|
|
|
15
15
|
$.UP_ARROW = 38;
|
|
16
16
|
$.DOWN_ARROW = 40;
|