littlejsengine 1.18.28 → 1.19.3
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/FAQ.md +5 -0
- package/README.md +207 -199
- package/dist/littlejs.d.ts +2099 -48
- package/dist/littlejs.esm.js +16251 -10315
- package/dist/littlejs.esm.min.js +13 -1
- package/dist/littlejs.js +15747 -9888
- package/dist/littlejs.min.js +13 -1
- package/dist/littlejs.release.js +15719 -9867
- package/package.json +1 -1
- package/plugins/audioEffects.js +371 -0
- package/plugins/lightSystem.js +5 -3
- package/plugins/math3d.js +870 -0
- package/plugins/medalSystem.js +280 -280
- package/plugins/pluginExport.js +181 -115
- package/plugins/postProcess.js +241 -166
- package/plugins/render3d.js +4006 -0
- package/plugins/textureSheet.js +458 -458
- package/plugins/threejs.js +6 -1
- package/plugins/tweenSystem.js +528 -526
- package/plugins/zzfxm.js +159 -166
- package/src/engine.js +172 -137
- package/src/engineAudio.js +918 -775
- package/src/engineBuild.mjs +3 -0
- package/src/engineDebug.js +15 -8
- package/src/engineDraw.js +1672 -1510
- package/src/engineExport.js +407 -396
- package/src/engineInput.js +1 -1
- package/src/engineLogo.js +4 -3
- package/src/engineMath.js +69 -0
- package/src/engineObject.js +560 -551
- package/src/engineSettings.js +759 -725
- package/src/engineTileLayer.js +3 -3
- package/src/engineUtilities.js +13 -0
- package/src/engineWebGL.js +1005 -941
package/src/engineTileLayer.js
CHANGED
|
@@ -230,10 +230,10 @@ class CanvasLayer extends EngineObject
|
|
|
230
230
|
ASSERT(isVector2(canvasSize), 'canvasSize must be a Vector2');
|
|
231
231
|
super(pos, size, undefined, angle, WHITE, renderOrder);
|
|
232
232
|
|
|
233
|
-
/** @property {HTMLCanvasElement} - The canvas used by this layer */
|
|
234
|
-
this.canvas = headlessMode ? undefined : new OffscreenCanvas(canvasSize.x, canvasSize.y);
|
|
235
233
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
236
|
-
this.context =
|
|
234
|
+
this.context = headlessMode ? undefined : createCanvasContext(canvasSize.x, canvasSize.y);
|
|
235
|
+
/** @property {OffscreenCanvas} - The canvas used by this layer */
|
|
236
|
+
this.canvas = this.context?.canvas;
|
|
237
237
|
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
238
238
|
this.textureInfo = new TextureInfo(this.canvas, useWebGL);
|
|
239
239
|
|
package/src/engineUtilities.js
CHANGED
|
@@ -135,6 +135,19 @@ async function fetchJSON(url)
|
|
|
135
135
|
function saveText(text, filename='text', type='text/plain')
|
|
136
136
|
{ saveDataURL(URL.createObjectURL(new Blob([text], {'type':type})), filename); }
|
|
137
137
|
|
|
138
|
+
/** Create an offscreen canvas to draw into, and return its 2D context
|
|
139
|
+
* - The canvas is context.canvas, which is what TextureInfo and the like take
|
|
140
|
+
* @param {number} width - In pixels
|
|
141
|
+
* @param {number} [height] - In pixels, defaults to the width for a square
|
|
142
|
+
* @param {boolean} [willReadFrequently] - Keep it in software, faster when getImageData is called on it often
|
|
143
|
+
* @return {OffscreenCanvasRenderingContext2D}
|
|
144
|
+
* @memberof Utilities */
|
|
145
|
+
function createCanvasContext(width, height=width, willReadFrequently=false)
|
|
146
|
+
{
|
|
147
|
+
ASSERT(isNumber(width) && isNumber(height), 'canvas width and height must be numbers', width, height);
|
|
148
|
+
return new OffscreenCanvas(width, height).getContext('2d', {willReadFrequently});
|
|
149
|
+
}
|
|
150
|
+
|
|
138
151
|
/** Save a canvas to disk
|
|
139
152
|
* @param {HTMLCanvasElement|OffscreenCanvas} canvas
|
|
140
153
|
* @param {string} [filename]
|