melonjs 20.9.0 → 20.10.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/build/application/settings.d.ts +12 -8
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1981 -237
- package/build/index.js.map +4 -4
- package/build/loader/loader.d.ts +62 -17
- package/build/loader/loader.d.ts.map +1 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +6 -0
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/state/state.d.ts.map +1 -1
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/squish.d.ts +74 -0
- package/build/video/effects/squish.d.ts.map +1 -0
- package/build/video/renderer.d.ts +16 -3
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +5 -0
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +21 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/deletable.d.ts +15 -0
- package/build/video/webgl/buffer/deletable.d.ts.map +1 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-effects-and-shaders/SKILL.md +50 -6
- package/skills/melonjs-loading-assets/SKILL.md +122 -13
- package/skills/melonjs-performance/SKILL.md +11 -3
- package/skills/melonjs-scenes-and-state/SKILL.md +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"AA2EA;;;;;;;;;;;;;;;GAeG;AACH,iDANW,OAAO,qBACP,OAAO,GACL;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CAYvD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH;IACC;;OAEG;IACH,qBAFW,mBAAmB,EA8W7B;IAtWA;;;;OAIG;IACH,kBAHU,UAAU,GAAC,SAAS,CAGN;IAExB;;;;OAIG;IACH,iBAHU,SAAS,GAAC,SAAS,CAGN;IAEvB;;;OAGG;IACH,SAFU,gBAAgB,CAEc;IAExC;;;;;OAKG;IACH,0BAHU,MAAM,GAAC,SAAS,CAGM;IAEhC;;;;;;;;;;;;;OAaG;IACH,cAJU,MAAM,GAAC,SAAS,CAIG;IAyC7B;mBACe;IACf,iEAAsC;IAGtC;;;OAGG;IACH,oBAAmC;IAInC,2BAAyD;IAKzD;mBACe;IACf,qBAA2B;IAG3B;mBACe;IACf;;;QAEE;IACF;mBACe;IACf,iBAAmB;IAEnB;mBACe;IACf,iBAA4B;IAE5B;mBACe;IACf,uBAAuB;IAEvB;;;;;OAKG;IACH,UAJU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAIJ;IAEzB;;;;OAIG;IACH,oBAA0B;IAG1B;mBACe;IACf,0CAAyB;IACzB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H,8BALW,MAAM,UACN,MAAM,QAsBhB;
|
|
1
|
+
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"AA2EA;;;;;;;;;;;;;;;GAeG;AACH,iDANW,OAAO,qBACP,OAAO,GACL;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CAYvD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH;IACC;;OAEG;IACH,qBAFW,mBAAmB,EA8W7B;IAtWA;;;;OAIG;IACH,kBAHU,UAAU,GAAC,SAAS,CAGN;IAExB;;;;OAIG;IACH,iBAHU,SAAS,GAAC,SAAS,CAGN;IAEvB;;;OAGG;IACH,SAFU,gBAAgB,CAEc;IAExC;;;;;OAKG;IACH,0BAHU,MAAM,GAAC,SAAS,CAGM;IAEhC;;;;;;;;;;;;;OAaG;IACH,cAJU,MAAM,GAAC,SAAS,CAIG;IAyC7B;mBACe;IACf,iEAAsC;IAGtC;;;OAGG;IACH,oBAAmC;IAInC,2BAAyD;IAKzD;mBACe;IACf,qBAA2B;IAG3B;mBACe;IACf;;;QAEE;IACF;mBACe;IACf,iBAAmB;IAEnB;mBACe;IACf,iBAA4B;IAE5B;mBACe;IACf,uBAAuB;IAEvB;;;;;OAKG;IACH,UAJU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAIJ;IAEzB;;;;OAIG;IACH,oBAA0B;IAG1B;mBACe;IACf,0CAAyB;IACzB;mBACe;IACf,sCAAuB;IAEvB;mBACe;IACf,qCAAsB;IACtB;mBACe;IACf,sCAAuB;IACvB;mBACe;IACf,wCAAwB;IAGxB;mBACe;IACf,yCAA0B;IAC1B;mBACe;IACf,wCAAsB;IAGtB;mBACe;IACf,+CAA+B;IAE/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,8CAAqC;IACrC;;;OAGG;IACH,2BAAsC;IACtC;;;OAGG;IACH,qDAAqC;IACrC;;;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BAAgB;0CA0BK,oCAAoC;yBAtBrD,qBAAqB;yBA1BrB,wBAAwB;uBAC1B,yBAAyB;gCA8CU,qBAAqB;8BAHjD,mBAAmB;8BACnB,yBAAyB;+BAMxB,oBAAoB;+BA3BpB,uCAAuC;wBAN9C,2BAA2B;6BAKtB,uCAAuC;8BAwCvC,4BAA4B;sBAhExB,qBAAqB;0BA4C5B,8BAA8B;8BAgB7B,wBAAwB;yBAF3B,2BAA2B;iCArClB,8BAA8B;6BAKrB,qBAAqB;6BAmCrC,6BAA6B;yCALjB,+BAA+B"}
|
package/package.json
CHANGED
|
@@ -110,14 +110,15 @@ reused across renderables.
|
|
|
110
110
|
|
|
111
111
|
## Built-in effects
|
|
112
112
|
|
|
113
|
-
Twenty-
|
|
113
|
+
Twenty-two presets, every one constructed as `new XEffect(renderer, options)` and
|
|
114
114
|
every one shipping both a GLSL and a WGSL body, so they all run on either GPU
|
|
115
115
|
backend: `VignetteEffect`, `ScanlineEffect` (optional CRT curvature),
|
|
116
116
|
`BloomEffect`, `GlowEffect`, `BlurEffect`, `PixelateEffect`,
|
|
117
117
|
`ChromaticAberrationEffect`, `DropShadowEffect`, `FlashEffect`,
|
|
118
118
|
`OutlineEffect`, `ColorMatrixEffect`, `DesaturateEffect`, `DissolveEffect`,
|
|
119
119
|
`TintPulseEffect`, `WaveEffect`, `InvertEffect`, `SepiaEffect`,
|
|
120
|
-
`HologramEffect`, `ShineEffect`, `RadialGradientEffect`, `
|
|
120
|
+
`HologramEffect`, `ShineEffect`, `RadialGradientEffect`, `SquishEffect`,
|
|
121
|
+
`ToneMappingEffect`.
|
|
121
122
|
|
|
122
123
|
`RadialGradientEffect` is a procedural soft spot: solid at the centre of its
|
|
123
124
|
host quad, fading linearly to transparent at the edge, and elliptical for free
|
|
@@ -127,6 +128,40 @@ falloff assumes the quad samples a FULL texture rect, so pair it with a
|
|
|
127
128
|
standalone image or `Renderer.getWhitePixel()` rather than a sprite that draws
|
|
128
129
|
a sub-region of an atlas, where the centre would land off-quad.
|
|
129
130
|
|
|
131
|
+
`SquishEffect` bulges a sprite's middle out (`setBulge(0.3)`) or pinches it in
|
|
132
|
+
(`setBulge(-0.3)`), its top and bottom rows staying put. Bulging out widens the
|
|
133
|
+
sprite past its own frame, and the effect draws on a wider quad to make room,
|
|
134
|
+
so the art needs no transparent margin. On its own it is a jelly wobble; paired
|
|
135
|
+
with a change of height it is **squash and stretch that keeps the volume**:
|
|
136
|
+
scale the sprite to `scaleY` of its height about its feet and set the bulge to
|
|
137
|
+
`1 - scaleY`, so a stretched sprite pinches in and a squashed one bulges out.
|
|
138
|
+
Ease `scaleY` back to 1 with a short `Tween.Easing.Back.Out`; an elastic ease
|
|
139
|
+
keeps it trembling long after the landing.
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
const squish = new SquishEffect(app.renderer);
|
|
143
|
+
player.addPostEffect(squish);
|
|
144
|
+
// every frame, from the player's update()
|
|
145
|
+
const feet = player.height * (1 - player.anchorPoint.y);
|
|
146
|
+
player.currentTransform
|
|
147
|
+
.identity()
|
|
148
|
+
.translate(0, feet)
|
|
149
|
+
.scale(1, scaleY)
|
|
150
|
+
.translate(0, -feet);
|
|
151
|
+
squish.setBulge(1 - scaleY);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Apply that from the sprite's own `update()`, not from a tween's `onUpdate`. A
|
|
155
|
+
physics adapter that mirrors a body's angle (Matter does) rewrites
|
|
156
|
+
`currentTransform` on every step, before the renderables update, so a scale set
|
|
157
|
+
anywhere else is gone by the time the sprite is drawn. Let the tween animate a
|
|
158
|
+
plain `{ scaleY }` object and read it in `update()`.
|
|
159
|
+
|
|
160
|
+
It is made for a sprite carrying it as its only effect: chained with another,
|
|
161
|
+
or on the camera, the frame it measures against is the whole capture, so it
|
|
162
|
+
squishes the whole frame. The bulge is outside the sprite's bounds, so culling
|
|
163
|
+
and pointer events ignore it.
|
|
164
|
+
|
|
130
165
|
**`BloomEffect` and `GlowEffect` are not the same thing**, and reaching for the
|
|
131
166
|
wrong one is the usual disappointment here. `GlowEffect` draws a halo OUTSIDE a
|
|
132
167
|
sprite's silhouette: its body returns the colour untouched wherever alpha is
|
|
@@ -453,8 +488,15 @@ With `prewarm` on (the default since 20.6), `loader.preload()` warms on its way
|
|
|
453
488
|
through — automatically, on every call — and compiles the GPU-side objects for
|
|
454
489
|
every shader it holds — on WebGPU that is the
|
|
455
490
|
WGSL module, which is otherwise built inside the draw path the first time the
|
|
456
|
-
effect is used.
|
|
457
|
-
|
|
491
|
+
effect is used.
|
|
492
|
+
|
|
493
|
+
Since 20.10 the rest is warmed when the effect is **attached**, inline effects
|
|
494
|
+
included: `addPostEffect` (or assigning `shader`) compiles the pipelines that
|
|
495
|
+
effect will draw with on that renderable — on WebGPU the costly part, keyed by
|
|
496
|
+
the renderable's blend mode and target as well as the shader — and on WebGL
|
|
497
|
+
links the spliced program when the host is a mesh. It finishes off the frame,
|
|
498
|
+
so attach when you build (a pool, a stage starting), not when you show: an
|
|
499
|
+
effect attached and drawn in the same frame still compiles on that frame.
|
|
458
500
|
|
|
459
501
|
One caveat if you are moving an inline effect to a file: a template literal can
|
|
460
502
|
interpolate constants into the source (`vec2(${ASPECT}, 1.0)`), and a static
|
|
@@ -470,8 +512,8 @@ uniform values — fine when the look is uniform, and the reason to clone (and
|
|
|
470
512
|
pay a link) when it is not.
|
|
471
513
|
|
|
472
514
|
Note this covers **your** effects only. The engine's own mesh/quad shader
|
|
473
|
-
variants are
|
|
474
|
-
|
|
515
|
+
variants are covered by the loading-screen warm-up and by the per-renderable one
|
|
516
|
+
— see `melonjs-loading-assets`.
|
|
475
517
|
|
|
476
518
|
### Screen-reading builtins
|
|
477
519
|
|
|
@@ -609,6 +651,8 @@ same question after construction.
|
|
|
609
651
|
| shadow/smear offset flips on some draws | vertical UV offset not multiplied by `uUVYDir` |
|
|
610
652
|
| frame rate collapses with many blended sprites | an *advanced* mode (overlay, darken, …) — each draw is a capture plus a composite |
|
|
611
653
|
| animated shader never moves | `setTime` fed milliseconds, or the shader declares no `uTime` |
|
|
654
|
+
| squash and stretch only bulges, the height never changes, under Matter | the adapter rewrites `currentTransform` every step; set the scale from the sprite's `update()` |
|
|
655
|
+
| `SquishEffect` squishes the whole screen instead of the sprite | it is chained with another effect, or on the camera; give the sprite it alone |
|
|
612
656
|
| syntax error in a file whose shader you just edited, pointing at a line of GLSL | a backtick in the shader body ended the template literal — most often one wrapped around an identifier in a comment |
|
|
613
657
|
|
|
614
658
|
## Related skills
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-loading-assets
|
|
3
|
-
description: "Use this skill for loading and managing game assets in melonJS — the resource descriptor format, the full asset type list, preload versus load, retrieving loaded assets, base URLs and cross-origin settings, and the loading screen. Triggers on: loader, loader.preload, loader.load, resources, getImage, getJSON, getTMX, getGLTF, getVideo, getFont, setBaseURL, setOptions, crossOrigin, withCredentials, credentials, cookies, authenticated assets, CORS, asset, preload, LOADER_COMPLETE, loading screen, unload."
|
|
3
|
+
description: "Use this skill for loading and managing game assets in melonJS — the resource descriptor format, the full asset type list, preload versus load, retrieving loaded assets, base URLs and cross-origin settings, and the loading screen. Triggers on: loader, loader.preload, loader.load, resources, getImage, getJSON, getTMX, getGLTF, getVideo, getFont, setBaseURL, setOptions, crossOrigin, withCredentials, credentials, cookies, authenticated assets, CORS, asset, preload, LOADER_COMPLETE, loading screen, unload, setParser, custom asset type, generated texture, procedural texture."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -50,6 +50,7 @@ The type strings are melonJS-specific — this is not a generic loader:
|
|
|
50
50
|
| `"obj"` / `"mtl"` | Wavefront models and materials |
|
|
51
51
|
| `"gltf"` / `"glb"` | glTF scenes |
|
|
52
52
|
| `"js"` | scripts |
|
|
53
|
+
| any type you register | your own formats, and things you generate rather than download — see [Custom asset types](#custom-asset-types) |
|
|
53
54
|
|
|
54
55
|
## What belongs in the manifest — and what cannot
|
|
55
56
|
|
|
@@ -84,14 +85,24 @@ is compiled at load time, behind the loading screen, and the loader hands out a
|
|
|
84
85
|
renderable's teardown freeing it out from under the others. `clone()` does NOT
|
|
85
86
|
help here — it constructs a new effect, and therefore links a new program.
|
|
86
87
|
|
|
87
|
-
**2. Derived assets — build once,
|
|
88
|
-
`NoiseTexture2d`, `TextureAtlas`: the
|
|
89
|
-
not be rebuilt per scene either. The renderer's texture cache is
|
|
90
|
-
**image object**, so a freshly baked canvas is a brand new GPU
|
|
91
|
-
new mip chain — rebuild one per stage and a title → play →
|
|
92
|
-
uploads four copies of the same pixels. Build
|
|
93
|
-
|
|
94
|
-
`TextureAtlas
|
|
88
|
+
**2. Derived assets — build once, before the first stage.** Canvases you bake,
|
|
89
|
+
`NoiseTexture2d`, `TextureAtlas`: none of the built-in types describes these,
|
|
90
|
+
and they must not be rebuilt per scene either. The renderer's texture cache is
|
|
91
|
+
keyed by the **image object**, so a freshly baked canvas is a brand new GPU
|
|
92
|
+
texture with a new mip chain — rebuild one per stage and a title → play →
|
|
93
|
+
game-over cycle uploads four copies of the same pixels. Build each once and
|
|
94
|
+
share it from a module the scenes read from, the way the platformer example
|
|
95
|
+
builds its `TextureAtlas`.
|
|
96
|
+
|
|
97
|
+
*Where* you build it depends on what it costs. A gradient or a palette strip is
|
|
98
|
+
well under a millisecond: build it after `preload` resolves. A bake that takes
|
|
99
|
+
real time — procedural noise is the usual one: Earth Defender's sky, two fractal
|
|
100
|
+
simplex fields over a 512² tile, takes about 200ms on a desktop — belongs
|
|
101
|
+
**inside** the preload as an asset type of your
|
|
102
|
+
own ([Custom asset types](#custom-asset-types)). It then runs behind the loading
|
|
103
|
+
screen and counts on the progress bar. Built on stage entry instead, it lands on
|
|
104
|
+
the frame the scene is assembled, and with a transition running that frame is a
|
|
105
|
+
black screen.
|
|
95
106
|
|
|
96
107
|
**3. The engine's own shader programs — warmed for you, since 20.6.** The mesh
|
|
97
108
|
batcher compiles a program per *feature combination* (instance colours, instance
|
|
@@ -111,13 +122,31 @@ the assets are in and **before** `LOADER_COMPLETE` fires, so it happens while
|
|
|
111
122
|
the progress bar is still up. Every `preload()` warms, not just the first, so a
|
|
112
123
|
per-level preload warms whatever that level brought with it.
|
|
113
124
|
|
|
114
|
-
The one precondition: **a game that never calls
|
|
115
|
-
|
|
125
|
+
The one precondition for this part: **a game that never calls
|
|
126
|
+
`loader.preload()` does not get it**. If you load assets another way, call
|
|
116
127
|
`await app.renderer.prewarm()` yourself. On
|
|
117
128
|
WebGL that links the mesh batchers' variants, for the unlit tier and the lit
|
|
118
129
|
one that inherits from it; on WebGPU it compiles the
|
|
119
|
-
WGSL module of every shader the loader holds
|
|
120
|
-
|
|
130
|
+
WGSL module of every shader the loader holds, and the mip-chain blitter when
|
|
131
|
+
textures are filtered.
|
|
132
|
+
|
|
133
|
+
**4. Everything that depends on the renderable — warmed as you build, since
|
|
134
|
+
20.10.** The rest cannot be done at preload, because it depends on what draws:
|
|
135
|
+
on WebGPU a *pipeline* is keyed by blend mode, culling, transparency and the
|
|
136
|
+
format of the target as well as by shader, and that compile is the expensive
|
|
137
|
+
part (tens of milliseconds, up to 140ms measured, per effect). So, behind the
|
|
138
|
+
same `prewarm` setting, the engine warms a renderable when it gains an effect
|
|
139
|
+
(`addPostEffect`, or assigning `shader`) and when it is added to the world:
|
|
140
|
+
its effect pipelines, its own draw, the render targets its chain composites
|
|
141
|
+
through, the advanced-blend shader if it uses one. Inline effects are covered
|
|
142
|
+
too; on WebGL that means linking a mesh-hosted effect's spliced program.
|
|
143
|
+
|
|
144
|
+
That work starts after your code has run and finishes off the frame, so it
|
|
145
|
+
needs **at least a frame between setting a renderable up and drawing it**. The
|
|
146
|
+
pattern that gets it for free is the one you want anyway: build pools (and
|
|
147
|
+
attach their effects) when the stage starts, then show and hide them during
|
|
148
|
+
play. Something created and drawn in the same frame still compiles on that
|
|
149
|
+
frame.
|
|
121
150
|
|
|
122
151
|
Cost to a game that uses none of it is about 60ms of preload on a desktop GPU.
|
|
123
152
|
Set it to `false` only for a target where linking is slow enough that the
|
|
@@ -212,6 +241,83 @@ loader.getBinary("font-fnt");
|
|
|
212
241
|
Most engine classes take the asset **name** directly, so you often do not need
|
|
213
242
|
these — `new Sprite(x, y, { image: "tiles" })` resolves it for you.
|
|
214
243
|
|
|
244
|
+
## Custom asset types
|
|
245
|
+
|
|
246
|
+
`loader.setParser(type, parserFn)` teaches the loader a type of its own. An entry
|
|
247
|
+
of that type then sits in the preload list like any other: it is one step of the
|
|
248
|
+
progress bar, and `preload()` waits for it before `LOADER_COMPLETE`. Use it for a
|
|
249
|
+
file format melonJS does not know, and for anything you **generate** that takes
|
|
250
|
+
long enough to matter.
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
import { loader, Sprite } from "melonjs";
|
|
254
|
+
|
|
255
|
+
const skies = new Map();
|
|
256
|
+
|
|
257
|
+
// once, before preloading: registering a type twice logs a warning
|
|
258
|
+
loader.setParser("sky", (asset, onload, onerror) => {
|
|
259
|
+
bakeSky(asset.name) // your generator, returning a Promise
|
|
260
|
+
.then((canvas) => {
|
|
261
|
+
skies.set(asset.name, canvas);
|
|
262
|
+
onload(); // takes no value, see below
|
|
263
|
+
}, onerror);
|
|
264
|
+
return 1; // one asset, settling later
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
await loader.preload([
|
|
268
|
+
{ name: "nebula", type: "sky" }, // no src: nothing to download
|
|
269
|
+
// ...the rest of the manifest
|
|
270
|
+
]);
|
|
271
|
+
|
|
272
|
+
// in the stage, later: already baked
|
|
273
|
+
const backdrop = new Sprite(0, 0, { image: skies.get("nebula") });
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The contract:
|
|
277
|
+
|
|
278
|
+
- **Call `onload()` or `onerror(error)`, exactly once,** now or later. Return `1`
|
|
279
|
+
when you will, `0` when there is nothing to load (the loader then moves on
|
|
280
|
+
without waiting).
|
|
281
|
+
- **The loader keeps nothing for a type it does not know.** `onload` takes no
|
|
282
|
+
value, and `loader.getImage` and friends will not find your result. Keep it
|
|
283
|
+
yourself, keyed by `asset.name`, and read it from there.
|
|
284
|
+
- **`name` and `type` are a complete entry.** `src` is only for a type that
|
|
285
|
+
fetches something. `data` is typed for the built-in uses (a string, or a
|
|
286
|
+
`{glsl, wgsl}` pair), so for a generator's settings, keep a table in your own
|
|
287
|
+
module keyed by name and let the entry carry only the name. That also keeps
|
|
288
|
+
the preload and the stages from disagreeing on a seed.
|
|
289
|
+
- **Base URLs:** a `src` is prefixed only by `setBaseURL(yourType, …)`. The `"*"`
|
|
290
|
+
wildcard does not cover custom types.
|
|
291
|
+
- **Do not hold the main thread for the whole bake.** A parser runs alongside
|
|
292
|
+
the downloads, and a 200ms synchronous loop freezes the loading screen and
|
|
293
|
+
stalls every other asset's progress for that long. Bake in slices of a few
|
|
294
|
+
milliseconds and yield between them, with `setTimeout`, not
|
|
295
|
+
`requestAnimationFrame`, which stops in a background tab and would hold the
|
|
296
|
+
whole preload with it. Skip the yield while the tab is hidden: a background
|
|
297
|
+
tab runs timers about once a second, which turns a bake of 25 slices into 25
|
|
298
|
+
seconds, and there is no loading screen on show to keep smooth:
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
const bakeSky = async (name) => {
|
|
302
|
+
const { size, seed } = SKIES[name]; // your recipe table
|
|
303
|
+
const tile = startTile(size, seed); // set up the canvas and the noise
|
|
304
|
+
for (let y = 0; y < size; ) {
|
|
305
|
+
const start = performance.now();
|
|
306
|
+
while (y < size && performance.now() - start < 8) {
|
|
307
|
+
tile.fillRow(y++);
|
|
308
|
+
}
|
|
309
|
+
if (!document.hidden) {
|
|
310
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return tile.finish();
|
|
314
|
+
};
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The Earth Defender example does exactly this for its two nebula skies
|
|
318
|
+
(`fx/nebula.ts`): a `"nebula"` type, two name-only entries in its manifest, and
|
|
319
|
+
stages that ask for a sky by name and find it baked.
|
|
320
|
+
|
|
215
321
|
## Base URLs
|
|
216
322
|
|
|
217
323
|
Set a prefix per asset type rather than repeating it:
|
|
@@ -308,6 +414,9 @@ throws, the same trap as the removed `loader.onload` / `onProgress`.
|
|
|
308
414
|
| text renders in a fallback font | web font not preloaded as `"fontface"` |
|
|
309
415
|
| `BitmapText` renders nothing | the `.fnt` (as `"binary"`) or its image is missing |
|
|
310
416
|
| `TypeError` assigning `loader.onProgress` / `onload` | removed in 20.3; they were never writable — use the `LOADER_*` events |
|
|
417
|
+
| `load : unknown or invalid resource type` | a custom type in the manifest before its `loader.setParser` call |
|
|
418
|
+
| black or frozen screen when a stage is first entered, the profile shows your own code (noise, a canvas bake) | a costly derived asset built on stage entry — bake it inside the preload as a [custom asset type](#custom-asset-types) |
|
|
419
|
+
| a custom asset preloads but the result is nowhere to be found | `onload` takes no value and the loader stores nothing for custom types — keep the result in your own module |
|
|
311
420
|
|
|
312
421
|
## Related skills
|
|
313
422
|
|
|
@@ -245,9 +245,16 @@ Since 20.6 the engine's own programs are built during `preload()` instead —
|
|
|
245
245
|
`loader.preload()` calls `renderer.prewarm()` itself, on every call, when the
|
|
246
246
|
application's `prewarm` setting is on, which is the default. So on a current
|
|
247
247
|
version this is one cause you can rule out before looking further, **unless the
|
|
248
|
-
game does not use the preloader at all**, which is the one way to miss it — see `melonjs-loading-assets`.
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
game does not use the preloader at all**, which is the one way to miss it — see `melonjs-loading-assets`. Since 20.10 the
|
|
249
|
+
pipelines that depend on the renderable (effects, blend modes, render targets)
|
|
250
|
+
are warmed when an effect is attached or a renderable is added to the world, as
|
|
251
|
+
long as that happens at least a frame before it is drawn: a pool built at stage
|
|
252
|
+
start is covered, an object created and drawn in the same frame is not. Since
|
|
253
|
+
20.10.1 a state change also holds the new stage's first frame until what its
|
|
254
|
+
`onResetEvent` built is warmed, for at most 1.5s, so the opening frame no longer
|
|
255
|
+
compiles them itself: a few milliseconds once the browser has compiled them
|
|
256
|
+
before, longer on a first visit. None of this covers the rest of what a first
|
|
257
|
+
frame pays for, below.
|
|
251
258
|
|
|
252
259
|
How to tell them apart, all from the page:
|
|
253
260
|
|
|
@@ -364,6 +371,7 @@ In rough order for a typical 2D game:
|
|
|
364
371
|
| memory grows with long music | missing `stream: true` |
|
|
365
372
|
| slow only on some machines | Canvas fallback — no GPU tilemap path |
|
|
366
373
|
| a freeze the first time a level shows, never again | shader variants linking on first draw — warm them behind the loading screen |
|
|
374
|
+
| a freeze the first time an effect appears mid-play (a shield, a hit flash) | the effect attached in the same frame it is drawn — attach it when the pool is built, so the warm-up has a frame to finish |
|
|
367
375
|
| the same scene stutters once per entry | a derived texture rebuilt per stage: the texture cache keys on the image object, so each rebuild is a new upload |
|
|
368
376
|
|
|
369
377
|
## Related skills
|
|
@@ -45,6 +45,13 @@ of on a deferred tick, which is what you want when changing state right after a
|
|
|
45
45
|
preload completes. It is ignored when a transition is configured — a transition
|
|
46
46
|
always drives the switch from its own completion callback.
|
|
47
47
|
|
|
48
|
+
`onResetEvent` runs when the switch is made. The first frame, `STATE_CHANGE` and
|
|
49
|
+
a transition's reveal follow once the shaders the stage queued are ready, which
|
|
50
|
+
is a few milliseconds once the browser has compiled them before, and at most
|
|
51
|
+
1.5s on a first visit. So build the stage in `onResetEvent`: an object a
|
|
52
|
+
`STATE_CHANGE` listener adds is not waited for, and its first draw may still
|
|
53
|
+
compile what it needs.
|
|
54
|
+
|
|
48
55
|
`state.change` **throws** `Undefined Stage for state '<id>'` if nothing was
|
|
49
56
|
registered for that id, and `state.set` throws if the second argument is not a
|
|
50
57
|
`Stage` instance. Neither fails quietly.
|