q5 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/q5.d.ts +697 -564
- package/q5.js +43 -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 +28 -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,10 @@ 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
|
+
$.preload ??= () => {};
|
|
206
|
+
$.setup ??= () => {};
|
|
207
|
+
$.draw ??= () => {};
|
|
199
208
|
let userFns = [
|
|
200
|
-
'setup',
|
|
201
|
-
'draw',
|
|
202
|
-
'preload',
|
|
203
209
|
'mouseMoved',
|
|
204
210
|
'mousePressed',
|
|
205
211
|
'mouseReleased',
|
|
@@ -220,15 +226,13 @@ function Q5(scope, parent, renderer) {
|
|
|
220
226
|
try {
|
|
221
227
|
return t[k]();
|
|
222
228
|
} catch (e) {
|
|
223
|
-
if ($.
|
|
229
|
+
if ($._askAI) $._askAI(e);
|
|
224
230
|
throw e;
|
|
225
231
|
}
|
|
226
232
|
};
|
|
227
233
|
}
|
|
228
234
|
}
|
|
229
235
|
|
|
230
|
-
if (!($.setup || $.draw)) return;
|
|
231
|
-
|
|
232
236
|
async function _start() {
|
|
233
237
|
$._startDone = true;
|
|
234
238
|
if ($._preloadCount > 0) return raf(_start);
|
|
@@ -236,19 +240,25 @@ function Q5(scope, parent, renderer) {
|
|
|
236
240
|
await $.setup();
|
|
237
241
|
$._setupDone = true;
|
|
238
242
|
if ($.frameCount) return;
|
|
239
|
-
if ($.ctx === null) $.createCanvas(
|
|
243
|
+
if ($.ctx === null) $.createCanvas(200, 200);
|
|
240
244
|
if ($.ctx) $.resetMatrix();
|
|
241
245
|
raf($._draw);
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} else {
|
|
248
|
-
t.preload = $.preload = () => {
|
|
248
|
+
function _preStart() {
|
|
249
|
+
try {
|
|
250
|
+
$.preload();
|
|
249
251
|
if (!$._startDone) _start();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
+
} catch (e) {
|
|
253
|
+
if ($._askAI) $._askAI(e);
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (preloadDefined || (arguments.length && scope != 'instance' && renderer != 'webgpu')) {
|
|
259
|
+
_preStart();
|
|
260
|
+
} else {
|
|
261
|
+
setTimeout(_preStart, 32);
|
|
252
262
|
}
|
|
253
263
|
}
|
|
254
264
|
|
|
@@ -259,7 +269,7 @@ Q5._nodejs = typeof process == 'object';
|
|
|
259
269
|
|
|
260
270
|
Q5._instanceCount = 0;
|
|
261
271
|
Q5._friendlyError = (msg, func) => {
|
|
262
|
-
console.error(func + ': ' + msg);
|
|
272
|
+
if (!Q5.disableFriendlyErrors) console.error(func + ': ' + msg);
|
|
263
273
|
};
|
|
264
274
|
Q5._validateParameters = () => true;
|
|
265
275
|
|
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;
|