melonjs 20.6.0 → 20.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/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +21324 -20390
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/level.d.ts +1 -0
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/lighting/light2d.d.ts +68 -2
- package/build/lighting/light2d.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +54 -0
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/fontface.d.ts +2 -0
- package/build/loader/parsers/fontface.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +143 -2
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +6 -16
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/sat.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts.map +1 -1
- package/build/physics/physicseditor.d.ts +2 -0
- package/build/physics/physicseditor.d.ts.map +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +2 -0
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +23 -1
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +39 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +72 -0
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +12 -9
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/state/stage.d.ts +22 -0
- package/build/state/stage.d.ts.map +1 -1
- package/build/video/buffer/vertex.d.ts.map +1 -1
- package/build/video/gpu/meshmaterial.d.ts +2 -0
- package/build/video/gpu/meshmaterial.d.ts.map +1 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +2 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +17 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-3d/SKILL.md +16 -0
- package/skills/melonjs-3d-assets/SKILL.md +51 -8
- package/skills/melonjs-lighting/SKILL.md +45 -1
- package/skills/melonjs-loading-assets/SKILL.md +1 -1
- package/skills/melonjs-physics/SKILL.md +320 -3
- package/skills/melonjs-renderables/SKILL.md +13 -0
- package/skills/melonjs-tilemaps/SKILL.md +9 -0
|
@@ -527,6 +527,22 @@ and spot, a stylised quadratic falloff, not inverse-square),
|
|
|
527
527
|
**`Light2d` is 2D-only** and produces visible artifacts under perspective
|
|
528
528
|
projection. Do not combine it with `Camera3d`.
|
|
529
529
|
|
|
530
|
+
**`lit: true` only does anything under a `Camera3d`.** Lighting a mesh needs
|
|
531
|
+
world-space normals and a world-space fragment position, and the 2D-camera path
|
|
532
|
+
has neither: its vertices are already the projected output, so there is no world
|
|
533
|
+
space left to light in. Such a mesh degrades to unlit and warns once, naming the
|
|
534
|
+
fix. If you want lit 3D props in an otherwise 2D game, set
|
|
535
|
+
`cameraClass: Camera3d` on the application. (For 2D **sprites**, lighting is a
|
|
536
|
+
separate system that works under a 2D camera as normal, see the lighting skill.)
|
|
537
|
+
|
|
538
|
+
A `lit` mesh takes a **tangent-space normal map**, so relief comes from the
|
|
539
|
+
material rather than from geometry — `settings.normalMap` (a loader key or any
|
|
540
|
+
image-like source), or MTL `map_bump` / `bump` / `norm`, which the MTL loader
|
|
541
|
+
fetches and applies per material. The tangent frame is derived per fragment, so
|
|
542
|
+
the model needs no tangent attribute, and an unmapped mesh is unaffected. This
|
|
543
|
+
is the 3D counterpart of the `Sprite` normal maps in the lighting skill; they
|
|
544
|
+
are separate systems and a `Mesh` uses this one.
|
|
545
|
+
|
|
530
546
|
Ground shadows are **on by default** (the `castGroundShadow` application
|
|
531
547
|
setting), and need a GPU backend and a `Camera3d`. As a blanket default they
|
|
532
548
|
skip geometry with no vertical extent — a ground plane. Per object,
|
|
@@ -63,6 +63,32 @@ level.load("diorama", { scale: 50, onLoaded: () => {
|
|
|
63
63
|
}});
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
### The same options from a Tiled `Trigger`
|
|
67
|
+
|
|
68
|
+
A `Trigger` authored in Tiled forwards these to `level.load()`, so a trigger that
|
|
69
|
+
walks the player into a glTF level carries the scene's settings as Tiled
|
|
70
|
+
properties:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
world.addChild(new Trigger(x, y, {
|
|
74
|
+
shapes: [new Rect(0, 0, 100, 100)],
|
|
75
|
+
to: "diorama", // the level id — `to`, not `level`
|
|
76
|
+
scale: 50,
|
|
77
|
+
rightHanded: false,
|
|
78
|
+
castGroundShadow: false,
|
|
79
|
+
}));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`scale`, `rightHanded`, `lights`, `lightIntensityScale`, `castGroundShadow` and
|
|
83
|
+
`shadowGroundY` all travel, and so do `container`, `onLoaded`, `flatten` and
|
|
84
|
+
`setViewportBounds`. That list is **hardcoded** in `Trigger` — a `level.load`
|
|
85
|
+
option outside it is dropped without a warning.
|
|
86
|
+
|
|
87
|
+
**`async` is deliberately excluded.** A trigger with a `color` + `duration`
|
|
88
|
+
sets it itself, because it needs the promise to sequence its fade and reveal; a
|
|
89
|
+
trigger without one loads fire-and-forget and never sets it. Either way an
|
|
90
|
+
authored `async` property is ignored rather than honoured.
|
|
91
|
+
|
|
66
92
|
## `rightHanded` — and the default that differs between the two APIs
|
|
67
93
|
|
|
68
94
|
glTF is authored **Y-up, right-handed**; melonJS is **Y-down, +Z forward**.
|
|
@@ -226,16 +252,33 @@ const mesh = new Mesh(400, 300, {
|
|
|
226
252
|
world.addChild(mesh);
|
|
227
253
|
```
|
|
228
254
|
|
|
229
|
-
**The MTL loader fetches the textures it references itself** — `map_Kd
|
|
230
|
-
`map_d` are resolved relative to the `.mtl` and preloaded for
|
|
231
|
-
no image entry in the manifest above. Passing `texture:`
|
|
232
|
-
that and pins *one* binding over the whole model, which on
|
|
233
|
-
model suppresses the per-material texture split; leave it out
|
|
234
|
-
that.
|
|
255
|
+
**The MTL loader fetches the textures it references itself** — `map_Kd`,
|
|
256
|
+
`map_d` and `map_bump` are resolved relative to the `.mtl` and preloaded for
|
|
257
|
+
you, so there is no image entry in the manifest above. Passing `texture:`
|
|
258
|
+
explicitly overrides that and pins *one* binding over the whole model, which on
|
|
259
|
+
a multi-material model suppresses the per-material texture split; leave it out
|
|
260
|
+
unless you mean that.
|
|
235
261
|
|
|
236
262
|
MTL contributes `Kd` (diffuse tint), `d` / `Tr` (opacity), `Ke` (emissive),
|
|
237
|
-
`Ks` + `Ns` (specular highlight), `map_Kd` (diffuse texture)
|
|
238
|
-
(per-texel opacity)
|
|
263
|
+
`Ks` + `Ns` (specular highlight), `map_Kd` (diffuse texture), `map_d`
|
|
264
|
+
(per-texel opacity) and `map_bump` / `bump` / `norm` (tangent-space normal
|
|
265
|
+
map — needs `lit: true`, and the tangent frame is derived per fragment, so the
|
|
266
|
+
model needs no tangent attribute). All three normal-map spellings are read as
|
|
267
|
+
normal maps even though the format specifies two of them as height maps, which
|
|
268
|
+
is what every exporter actually writes. Specular *maps* (`map_Ks`) and the PBR
|
|
269
|
+
extension's `map_Pr` / `map_Pm` are not supported and warn — the `Pr` / `Pm`
|
|
270
|
+
*scalars* are read and approximated onto the specular terms, the maps would
|
|
271
|
+
need a real PBR model.
|
|
272
|
+
|
|
273
|
+
`Ka` (ambient) and `illum` (illumination model) are read onto the material and
|
|
274
|
+
readable from `loader.getMTL(name)`, but take no part in shading. That is
|
|
275
|
+
deliberate rather than pending: `Ka` predates scene-wide ambient light and would
|
|
276
|
+
fight `Stage.ambientLightingColor`, and `illum` enumerates fixed-function
|
|
277
|
+
behaviours this renderer has no equivalent for. In particular an `illum` of 0 or
|
|
278
|
+
1 nominally means "no specular", and the engine does **not** honour that — `Ns`
|
|
279
|
+
stays the only gate, so a model that renders correctly today is not restyled by
|
|
280
|
+
a field its exporter wrote inconsistently.
|
|
281
|
+
|
|
239
282
|
`loader.getOBJ(name)` and `loader.getMTL(name)` return the parsed data if you
|
|
240
283
|
want it directly. OBJ has no scene graph, no lights, no animation — use glTF for
|
|
241
284
|
anything beyond a single static model.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-lighting
|
|
3
|
-
description: "Use this skill for 2D dynamic lighting in melonJS — Light2d, ambient light on a Stage, multiple lights, and per-pixel normal-mapped sprites authored in SpriteIlluminator. Covers the ambient-cutout model, which parts need a GPU backend, and why Light2d does not survive a Camera3d. Triggers on: Light2d, lighting, ambientLight, ambientLightingColor, normalMap, SpriteIlluminator, per-pixel lighting, drawLight, torch, glow, darkness."
|
|
3
|
+
description: "Use this skill for 2D dynamic lighting in melonJS — Light2d, ambient light on a Stage, multiple lights, and per-pixel normal-mapped sprites authored in SpriteIlluminator. Covers specular highlights via shininess, the ambient-cutout model, which parts need a GPU backend, and why Light2d does not survive a Camera3d. Triggers on: Light2d, specular, shininess, highlight, glint, lighting, ambientLight, ambientLightingColor, normalMap, SpriteIlluminator, per-pixel lighting, drawLight, torch, glow, darkness."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -83,6 +83,50 @@ atlas can carry one too: `new TextureAtlas(json, image, { normalMap })` pairs a
|
|
|
83
83
|
normal texture sharing the colour texture's UVs, and a `Sprite` built from that
|
|
84
84
|
atlas picks it up in preference to its own `settings.normalMap`.
|
|
85
85
|
|
|
86
|
+
## Specular highlights
|
|
87
|
+
|
|
88
|
+
A normal map gives a sprite **shape**: the light knows which way each texel
|
|
89
|
+
faces, so a torch reveals bumps and crevices. `shininess` decides whether it
|
|
90
|
+
also **shines**:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const sword = new Sprite(x, y, {
|
|
94
|
+
image: "sword",
|
|
95
|
+
normalMap: "sword_n",
|
|
96
|
+
shininess: 64, // 0 (the default) is matte
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The difference is what the highlight *does*. Diffuse brightness depends only on
|
|
101
|
+
the angle between the surface and the light, so a torch moving past just makes
|
|
102
|
+
the sprite brighter. A specular highlight only appears where a texel reflects
|
|
103
|
+
the light **toward the screen**, so it slides across the surface as the light
|
|
104
|
+
moves: armour that glints as you walk by, rather than armour that is merely lit.
|
|
105
|
+
|
|
106
|
+
Low values give a broad sheen (worn metal, wet stone); high values a tight glint
|
|
107
|
+
(polished steel, glass). It is gated on the exponent exactly as MTL `Ns` is on
|
|
108
|
+
the 3D path, so `0` means matte however bright the scene, and a sprite that
|
|
109
|
+
never sets it renders exactly as it always did.
|
|
110
|
+
|
|
111
|
+
Three things worth knowing:
|
|
112
|
+
|
|
113
|
+
- **It needs a `normalMap`.** With no surface directions there is nothing to
|
|
114
|
+
reflect, and the sprite stays matte whatever `shininess` says.
|
|
115
|
+
- **The normal map's alpha channel masks it per texel.** 255 is fully
|
|
116
|
+
reflective, 0 is dead matte, so one sprite can be a shiny blade with a matte
|
|
117
|
+
leather grip. A normal map with no alpha detail (the usual case) shines
|
|
118
|
+
uniformly. Note the corollary: if your normal map already uses alpha for
|
|
119
|
+
something, that channel now also decides gloss.
|
|
120
|
+
- **It accumulates per light.** Each light contributes its own highlight in its
|
|
121
|
+
own colour, so a sprite between a warm lamp and a cool one carries two
|
|
122
|
+
distinct glints that move independently.
|
|
123
|
+
|
|
124
|
+
The highlight takes the light's own colour and is *added* on top of the lit
|
|
125
|
+
result rather than multiplied into it, which is why a glint blows out toward
|
|
126
|
+
white on a dark sprite instead of tinting with it.
|
|
127
|
+
|
|
128
|
+
See it running: [Normal Map example](https://melonjs.github.io/melonJS/examples/#/normal-map).
|
|
129
|
+
|
|
86
130
|
Unlit areas of a normal-mapped sprite render pure black unless you raise
|
|
87
131
|
`Stage.ambientLightingColor` (default black) — that is the base level added to
|
|
88
132
|
every lit pixel, and it is a different knob from `Stage.ambientLight`.
|
|
@@ -39,7 +39,7 @@ The type strings are melonJS-specific — this is not a generic loader:
|
|
|
39
39
|
| type | for |
|
|
40
40
|
|---|---|
|
|
41
41
|
| `"image"` | textures, sprite sheets, normal maps |
|
|
42
|
-
| `"json"` | data, texture-atlas descriptors |
|
|
42
|
+
| `"json"` | data, texture-atlas descriptors, collision shapes from a shape editor |
|
|
43
43
|
| `"tmx"` / `"tsx"` | Tiled maps and external tilesets |
|
|
44
44
|
| `"audio"` | sound — **`src` is a directory**, see below |
|
|
45
45
|
| `"video"` | video textures |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-physics
|
|
3
|
-
description: "Use this skill for collision, physics bodies, movement, and spatial queries in melonJS — the built-in SAT world and the planck/matter adapters. Covers bodyDef vs Body, collision types and masks, the collision callback family and their firing rules, raycast/queryAABB/querySphere,
|
|
3
|
+
description: "Use this skill for collision, physics bodies, movement, and spatial queries in melonJS — the built-in SAT world and the planck/matter adapters. Covers bodyDef vs Body, collision types and masks, the collision callback family and their firing rules, raycast/queryAABB/querySphere, the behaviour differences between adapters, and which one to pick for a given game. Triggers on: which physics engine, choosing an adapter, rotation collision, rotating body, torque, joints, stacking, Body, bodyDef, collision, collisionType, collisionMask, onCollision, onCollisionStart, onCollisionActive, raycast, queryAABB, querySphere, PlanckAdapter, MatterAdapter, gravity, velocity, applyForce, isGrounded, SAT."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -19,6 +19,61 @@ license: MIT
|
|
|
19
19
|
| **`@melonjs/planck-adapter`** | Full rigid-body dynamics — stacking, joints, realistic restitution. |
|
|
20
20
|
| **`@melonjs/matter-adapter`** | Same class of thing, backed by matter-js. |
|
|
21
21
|
|
|
22
|
+
### Picking one
|
|
23
|
+
|
|
24
|
+
Start with the built-in. It is the default for a reason: no dependency, the
|
|
25
|
+
smallest bundle, and its position-based model is what most 2D games actually
|
|
26
|
+
want — a platformer's jump arc is a designed curve, not a simulated one, and
|
|
27
|
+
tuning gravity against a solver you are fighting is a bad afternoon.
|
|
28
|
+
|
|
29
|
+
**Move to an adapter when the game needs something the builtin cannot express**,
|
|
30
|
+
and these are the usual triggers:
|
|
31
|
+
|
|
32
|
+
- **Rotation that collides.** The clearest signal. The builtin's SAT never reads
|
|
33
|
+
`body.angle`, so a spinning shape collides as though it never turned. See
|
|
34
|
+
the note in *Built-in world quirks* below.
|
|
35
|
+
- **Torque, angular velocity, or spin from an impact.** Anything that should
|
|
36
|
+
start turning *because* it was hit.
|
|
37
|
+
- **Joints and constraints** — ragdolls, chains, ropes, vehicles, hinged doors.
|
|
38
|
+
The builtin has no concept of them.
|
|
39
|
+
- **Stacking and resting contacts.** Boxes that pile up and stay put need an
|
|
40
|
+
iterative solver. The builtin resolves each contact once per step with no
|
|
41
|
+
iteration pass, which splits three ways. A dynamic body resting on STATIC
|
|
42
|
+
geometry is exact, to the pixel, which is the platformer case it exists for.
|
|
43
|
+
A body squeezed between a dynamic body and static geometry is exact too: the
|
|
44
|
+
immovable side gets the casting vote and the other body absorbs the whole
|
|
45
|
+
correction, so a crate shoved against a wall stops at the wall. But a body
|
|
46
|
+
squeezed between two DYNAMIC bodies has no immovable side to defer to, so
|
|
47
|
+
those per-pair corrections still compete and it comes to rest slightly
|
|
48
|
+
overlapping. Three stacked 44px boxes rest flush on the floor with about 2px
|
|
49
|
+
of overlap inside the pile, and stay there: a stable equilibrium, not jitter
|
|
50
|
+
you can wait out or tune away.
|
|
51
|
+
- **Believable restitution and friction**, where a ball's bounce height and roll
|
|
52
|
+
should follow from its material rather than from code you wrote per case.
|
|
53
|
+
|
|
54
|
+
**Stay on the built-in when** the game is grid or tile based, movement is
|
|
55
|
+
authored rather than simulated, collision is "did these two boxes touch" plus a
|
|
56
|
+
push-out, or you are shipping to a tight bundle budget. Tiled maps, `Trigger`
|
|
57
|
+
and `Collectable` all work on every backend, so this is not a fork in the road
|
|
58
|
+
for level content.
|
|
59
|
+
|
|
60
|
+
**planck or matter?** Both are real rigid-body engines and either will do; the
|
|
61
|
+
adapters expose the same portable API, so a game can switch with an import
|
|
62
|
+
change and a gravity re-tune.
|
|
63
|
+
|
|
64
|
+
- **planck** (a Box2D port) is the more accurate and the more predictable under
|
|
65
|
+
stress: better stacking, better joint behaviour, a continuous-collision
|
|
66
|
+
`bullet` mode for fast movers. It works in **metres**, so it has a
|
|
67
|
+
`pixelsPerMeter` scale to think about, and its tuning vocabulary is Box2D's.
|
|
68
|
+
- **matter-js** works directly in **pixels**, which makes it the gentler
|
|
69
|
+
introduction, and its compound bodies and constraints are pleasant to author.
|
|
70
|
+
It is the softer solver: stacks settle less crisply and fast bodies need
|
|
71
|
+
`subSteps`.
|
|
72
|
+
|
|
73
|
+
If you have no preference and the game leans on stacking, joints or fast
|
|
74
|
+
projectiles, take planck. If you want to be up and running with the least
|
|
75
|
+
conversion to think about, take matter.
|
|
76
|
+
|
|
22
77
|
An adapter is an `Application` setting, not a plugin:
|
|
23
78
|
|
|
24
79
|
```js
|
|
@@ -44,6 +99,34 @@ body radius. Pick **one** adapter per game; `physic: "none"` disables physics
|
|
|
44
99
|
entirely — `world.step` skips the simulation and the world behaves as a pure
|
|
45
100
|
scene graph.
|
|
46
101
|
|
|
102
|
+
**Gravity is a different unit in every backend, and the defaults are NOT the
|
|
103
|
+
same speed.** Each is "Earth-like" in its own convention, but measured against
|
|
104
|
+
each other by timing a 200px free fall in one scene:
|
|
105
|
+
|
|
106
|
+
| backend | default | unit | measured fall |
|
|
107
|
+
|---|---|---|---|
|
|
108
|
+
| built-in | `0.98` | per FRAME, integrated against `timer.tick` | **~4450 px/s²** |
|
|
109
|
+
| matter | `{x: 0, y: 1}` | matter's own, after its internal `gravity.scale` | **~900 px/s²** |
|
|
110
|
+
| planck | `320` | pixels per second² | **~330 px/s²** |
|
|
111
|
+
|
|
112
|
+
That is a **thirteenfold spread**, so swapping the built-in world for an adapter
|
|
113
|
+
and keeping everything else the same makes the whole game feel different. It is
|
|
114
|
+
not a bug in either one: they simply do not share a unit.
|
|
115
|
+
|
|
116
|
+
To match a backend you are porting FROM, pick a target in px/s² and convert:
|
|
117
|
+
planck takes it directly; matter takes `target / 900`; the built-in takes
|
|
118
|
+
`target / 4450 * 0.98`, because it applies gravity per frame rather than per
|
|
119
|
+
second. Passing one number to two of them compares nothing: hand planck
|
|
120
|
+
matter's `{x: 0, y: 1}` and it runs at a three-hundredth of Earth gravity.
|
|
121
|
+
|
|
122
|
+
That mistake is quiet and it does not look like a gravity problem. Bodies fall
|
|
123
|
+
slowly enough that a spawner keeping a fixed interval starts constructing them
|
|
124
|
+
inside each other, and **a body born overlapping another is outside what a
|
|
125
|
+
solver promises to fix**: the contact normals of an interlocked pair can cancel
|
|
126
|
+
out, leaving the position solver with nowhere to push. The symptom is two
|
|
127
|
+
shapes permanently fused at rest, which reads as a broken collision shape
|
|
128
|
+
rather than as a bad gravity constant. Spawn clear of anything already there.
|
|
129
|
+
|
|
47
130
|
`world.physic` carries the active adapter's label (`"builtin"`, `"planck"`,
|
|
48
131
|
`"matter"`, `"none"`), so game code can branch without importing the class.
|
|
49
132
|
|
|
@@ -72,6 +155,19 @@ world; the broadphase picks the renderable up on the next `world.update()`.
|
|
|
72
155
|
Calling `adapter.addBody()` yourself registers the body but leaves the
|
|
73
156
|
renderable out of the scene graph, so it integrates but never collides.
|
|
74
157
|
|
|
158
|
+
**`fixedRotation` follows the engine, so bodies rotate.** Both matter and
|
|
159
|
+
planck default it to `false`, and so do the adapters from matter-adapter 1.4.0
|
|
160
|
+
and planck-adapter 1.5.0. Pass `fixedRotation: true` for anything that must
|
|
161
|
+
stay upright, such as a platformer actor. Earlier adapter versions locked
|
|
162
|
+
rotation unless told otherwise, which inverted the engine they wrap: bodies
|
|
163
|
+
landed holding whatever angle they were given and no collision could turn them,
|
|
164
|
+
while `setAngle()` still worked, so a body could look rotated while being
|
|
165
|
+
unable to rotate.
|
|
166
|
+
|
|
167
|
+
`frictionAir` damps **rotation as well as translation** on both adapters, so
|
|
168
|
+
it is also what settles a spin. Left at `0` a body that starts turning never
|
|
169
|
+
stops, which only became visible once rotation stopped being locked.
|
|
170
|
+
|
|
75
171
|
Other portable `bodyDef` fields: `density`, `frictionAir` (number or `{x, y}`),
|
|
76
172
|
`friction`, `restitution`, `gravityScale`, `maxVelocity`, `fixedRotation`,
|
|
77
173
|
`isSensor`, `userData`. Not every adapter honours every one — the built-in
|
|
@@ -106,6 +202,166 @@ For contacts reported per *shape pair* rather than per body pair, define
|
|
|
106
202
|
Declaring at least one of them opts into shape-pair enumeration; declaring none
|
|
107
203
|
costs nothing.
|
|
108
204
|
|
|
205
|
+
### Shapes drawn in a physics-shape editor
|
|
206
|
+
|
|
207
|
+
A visual collision-shape editor exports a JSON file holding a map of body name
|
|
208
|
+
to the fixtures authored for it. Preload it like any other JSON, then name it
|
|
209
|
+
from `bodyDef.shapes` with `id` naming the body to read:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
// in the preloader
|
|
213
|
+
{ name: "shapes", type: "json", src: "data/physics/shapes.json" }
|
|
214
|
+
|
|
215
|
+
// then, on the renderable
|
|
216
|
+
this.bodyDef = { type: "dynamic", shapes: "shapes", id: "hotdog" };
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
This works identically on the built-in, matter and planck adapters — the file is
|
|
220
|
+
resolved into real shapes before any adapter is handed the definition. Circles
|
|
221
|
+
and polygons both load, and a concave outline (exported already decomposed into
|
|
222
|
+
convex pieces) becomes one `Polygon` per piece.
|
|
223
|
+
|
|
224
|
+
The density, friction and bounce the shapes were authored with are carried onto
|
|
225
|
+
the body definition too, each honoured by whichever backends support it — the
|
|
226
|
+
built-in adapter ignores contact `friction`, as it does for a hand-written
|
|
227
|
+
definition. The format carries these per fixture, but only planck could honour
|
|
228
|
+
that, so they reduce onto the body and a file whose fixtures disagree warns. An
|
|
229
|
+
explicit field on the definition always wins:
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
// bounces at 0.9 whatever the file says
|
|
233
|
+
this.bodyDef = { type: "dynamic", shapes: "shapes", id: "hotdog", restitution: 0.9 };
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The exporting tool's own filter block is **not** read, in any spelling. Its
|
|
237
|
+
category and mask bits are numbers in that tool's namespace rather than
|
|
238
|
+
{@link collision.types}, and a template writes its defaults for every fixture
|
|
239
|
+
whether or not you set anything — importing them would silently tag a shape as
|
|
240
|
+
something it is not and stop it colliding. Set `collisionType` / `collisionMask`
|
|
241
|
+
on the body definition instead. A file written by hand may carry those two names
|
|
242
|
+
per fixture, and `isSensor`, which mean the same thing here as there.
|
|
243
|
+
|
|
244
|
+
Authored shapes and imported ones can sit in the same list.
|
|
245
|
+
|
|
246
|
+
Two bodies must never share one `shapes` array: a body **owns** its shapes and
|
|
247
|
+
rotating it mutates them in place. Naming the file sidesteps this — every body
|
|
248
|
+
resolved from it mints its own shapes.
|
|
249
|
+
|
|
250
|
+
`Body#fromJSON()` and passing an exported list to `addShape()` are the old,
|
|
251
|
+
built-in-only spelling of this and are deprecated since 20.7.0.
|
|
252
|
+
|
|
253
|
+
### Which shapes each backend can actually simulate
|
|
254
|
+
|
|
255
|
+
| shape | builtin | matter | planck |
|
|
256
|
+
|---|---|---|---|
|
|
257
|
+
| `Rect`, `Polygon` | exact | exact | exact, up to 12 vertices |
|
|
258
|
+
| `RoundRect` | exact | exact (decomposed) | sampled down to 12 vertices |
|
|
259
|
+
| `Ellipse` | exact | circle of the average radius | circle of the average radius |
|
|
260
|
+
| `Line` | exact | thin quad along the segment | thin quad along the segment |
|
|
261
|
+
| `Point`, `Box3d`, `Sphere` | supported | **throws** | **throws** |
|
|
262
|
+
|
|
263
|
+
Two of those are worth knowing before you author geometry. Box2D caps a
|
|
264
|
+
polygon's vertex count and says nothing when you go over: measured, a
|
|
265
|
+
16-point outline comes back with 12 vertices and a 36-point one collapses
|
|
266
|
+
from 70x36 to 47x18. A `RoundRect` carries 36 points, four corners of nine
|
|
267
|
+
arc segments each, so it is the usual way to meet that cap; the adapter now
|
|
268
|
+
samples it down and keeps the extent. Anything the 2D backends cannot express
|
|
269
|
+
is refused loudly on both, rather than leaving a body with no collision
|
|
270
|
+
geometry that silently never collides.
|
|
271
|
+
|
|
272
|
+
Whatever a backend really simulates is what `getBodyShapes()` reports, so the
|
|
273
|
+
debug panel is the fastest way to see an approximation for what it is.
|
|
274
|
+
|
|
275
|
+
### `Line` shapes, and why slopes need a rigid-body adapter
|
|
276
|
+
|
|
277
|
+
A `Line` is two points and no area, and it is what Tiled emits for every
|
|
278
|
+
polyline, so it is the natural way to author a slope or a strip of ground.
|
|
279
|
+
Neither rigid-body engine has a segment primitive, so both simulate one as a
|
|
280
|
+
thin quad following the segment (2px), which is what `getBodyShapes()` reports
|
|
281
|
+
back. Before 20.7 each substituted something of its own instead: matter the
|
|
282
|
+
line's bounding box, planck a one-metre square wherever the body happened to
|
|
283
|
+
be. Neither logged anything.
|
|
284
|
+
|
|
285
|
+
The builtin solver resolves a sloped segment too, and correctly: a body lands
|
|
286
|
+
on it and SLIDES down it, holding a constant distance from the surface while
|
|
287
|
+
its x advances. What it has no notion of is SURFACE friction. `def.friction`
|
|
288
|
+
is ignored entirely and `body.friction` is a per-step velocity damping vector
|
|
289
|
+
fed from `def.frictionAir`, so nothing removes the tangential component of
|
|
290
|
+
gravity. A body on an incline therefore accelerates down it forever and leaves
|
|
291
|
+
at the end, and in a valley of segments it swings from arm to arm for a while
|
|
292
|
+
before coming to rest on the flat. (It used to escape through an arm instead;
|
|
293
|
+
that was a separate defect in how a body was separated from a shape list, fixed
|
|
294
|
+
in 20.7.)
|
|
295
|
+
|
|
296
|
+
matter and planck both have real surface friction, so the same valley holds a
|
|
297
|
+
body still.
|
|
298
|
+
|
|
299
|
+
**Several shapes on one body.** A Tiled polyline arrives as ONE body carrying
|
|
300
|
+
one shape per segment, and until 20.7 a body resting on such a ground could
|
|
301
|
+
sink through one of the segments and drop out. The narrowphase reports the
|
|
302
|
+
FIRST overlapping shape pair it finds, and the compound resolution pass
|
|
303
|
+
re-ran that same first-hit-wins scan, so it kept re-resolving the pair it had
|
|
304
|
+
already resolved while a neighbour was penetrated unmeasured. Every pair is
|
|
305
|
+
enumerated now. If you are ever diagnosing something similar, the experiment
|
|
306
|
+
that localises it is to re-run the same geometry as SEVERAL single-shape
|
|
307
|
+
bodies: if that holds and one multi-shape body does not, the fault is in the
|
|
308
|
+
compound path rather than in the shape type.
|
|
309
|
+
|
|
310
|
+
Do not diagnose this by dropping a body and reading its final `y`. A body that
|
|
311
|
+
slid off the end of a ramp and a body that fell straight through it both end up
|
|
312
|
+
far below, and they look identical in that one number. Track the body against
|
|
313
|
+
the surface height at its CURRENT x instead: riding the slope shows a constant
|
|
314
|
+
offset while x advances.
|
|
315
|
+
|
|
316
|
+
So segments collide on every backend. If you need a body to come to REST on a
|
|
317
|
+
sloped one, use matter or planck, or damp it yourself: the builtin will slide
|
|
318
|
+
it down the incline indefinitely. The `Line Collision` example draws the
|
|
319
|
+
authored segment against the geometry each backend reports, which is the
|
|
320
|
+
quickest way to see what a backend is really simulating.
|
|
321
|
+
|
|
322
|
+
### `anchorPoint` moves the collision shapes with the drawing
|
|
323
|
+
|
|
324
|
+
`anchorPoint` says where in its own bounds a renderable sits on its `pos`:
|
|
325
|
+
`updateBounds()` translates its bounds by `-width * anchorPoint.x, -height *
|
|
326
|
+
anchorPoint.y`, and `preDraw` shifts its rendering by the same amount. A
|
|
327
|
+
body's collision shapes are measured from that same frame, so a shape of
|
|
328
|
+
`new Rect(0, 0, width, height)` covers the sprite whatever the anchor is, and
|
|
329
|
+
a shape's own `pos` still offsets it inside that frame (a small hitbox at the
|
|
330
|
+
feet, a hurtbox at the head).
|
|
331
|
+
|
|
332
|
+
This was broken until 20.7: shapes were measured from `pos` regardless of the
|
|
333
|
+
anchor, so anything not anchored at its top-left corner collided where it was
|
|
334
|
+
not drawn, by half a body at the default centred anchor and by a full body
|
|
335
|
+
height at the bottom anchor a platformer actor uses. If you compensated by
|
|
336
|
+
offsetting your shapes by hand, remove those offsets. `Entity` and Tiled
|
|
337
|
+
objects set their own anchor to `(0, 0)`, so nothing built either of those
|
|
338
|
+
ways is affected.
|
|
339
|
+
|
|
340
|
+
The debug panel is the quickest check: green is the renderable's bounds, red
|
|
341
|
+
is what actually collides, and the two now agree.
|
|
342
|
+
|
|
343
|
+
One renderable does not take that offset at all: one that has cleared
|
|
344
|
+
`applyAnchorTransform`, the flag `preDraw` reads before shifting anything.
|
|
345
|
+
`GLTFModel` sets it `false` outright and `Mesh` clears it under a `Camera3d`,
|
|
346
|
+
because both emit world coordinates and pivot about their own model origin
|
|
347
|
+
rather than a bounds box, so they draw at `pos` whatever their `anchorPoint`
|
|
348
|
+
still holds. Their bodies are built there too, on every backend, and
|
|
349
|
+
`raycast3d` reports hits in that same frame. If you clear the flag on a
|
|
350
|
+
renderable of your own, the same applies: you place it, and your shapes are
|
|
351
|
+
measured from `pos`.
|
|
352
|
+
|
|
353
|
+
### `autoTransform: false` opts out of rotated bounds
|
|
354
|
+
|
|
355
|
+
`updateBounds()` only applies `currentTransform` when `autoTransform` is
|
|
356
|
+
`true`. Turn it off and the renderable's bounds stay the UNROTATED frame
|
|
357
|
+
while the sprite turns inside them, which quietly feeds a wrong box to
|
|
358
|
+
frustum culling and to the broadphase. Measured on a 60x20 box at 90
|
|
359
|
+
degrees: `20x60` with `autoTransform` on, `60x20` with it off.
|
|
360
|
+
|
|
361
|
+
That flag means "I place myself", so it is a fair contract, but reach for it
|
|
362
|
+
only when you really are drawing in your own frame, and remember the bounds
|
|
363
|
+
are yours to keep honest then.
|
|
364
|
+
|
|
109
365
|
## Move with forces, not by assigning position
|
|
110
366
|
|
|
111
367
|
```js
|
|
@@ -311,6 +567,13 @@ real rigid-body engine:
|
|
|
311
567
|
- **Dynamic-dynamic collision is position-based, not Newtonian.** Separation is
|
|
312
568
|
mass-proportional but the velocity response is per-body cancellation — two
|
|
313
569
|
equal-mass bodies do not exchange momentum the way you would expect.
|
|
570
|
+
- **An immovable contact wins the step.** Each step records, per body, which
|
|
571
|
+
directions it has already been pushed out of, and a later dynamic-dynamic
|
|
572
|
+
contact will not push it back in one of those directions: the other body
|
|
573
|
+
takes the whole correction instead. A light body shoving a heavy one against
|
|
574
|
+
a wall therefore stops dead at the wall rather than driving it through, and
|
|
575
|
+
the shover absorbs all of the separation. The record lasts one step and is
|
|
576
|
+
not contact state — it says nothing about what a body is touching.
|
|
314
577
|
- **Gravity defaults to `(0, 0.98)`** — pixels per frame², not m/s². Mutate
|
|
315
578
|
`app.world.adapter.gravity` at runtime, or pass
|
|
316
579
|
`physic: new BuiltinAdapter({ gravity })` to override it. `body.gravityScale`
|
|
@@ -319,8 +582,7 @@ real rigid-body engine:
|
|
|
319
582
|
- **`applyForce(x, y)` is linear only** unless you pass the optional
|
|
320
583
|
`(pointX, pointY)` application point, which generates a torque
|
|
321
584
|
`τ = r × F` into `body.angularVelocity` via `body.pseudoInertia`.
|
|
322
|
-
`applyTorque(τ)` is the direct form.
|
|
323
|
-
collisions stay axis-aligned.
|
|
585
|
+
`applyTorque(τ)` is the direct form.
|
|
324
586
|
- **Force accumulators reset at end-of-step** — for every body, including
|
|
325
587
|
static, paused and off-screen ones — so forces must be applied every frame to
|
|
326
588
|
persist.
|
|
@@ -342,6 +604,50 @@ real rigid-body engine:
|
|
|
342
604
|
- **`addBody` throws on double-registration** for a renderable that is already
|
|
343
605
|
adapter-managed.
|
|
344
606
|
|
|
607
|
+
### Rotation collides on planck and matter, but not on the built-in solver
|
|
608
|
+
|
|
609
|
+
This is the sharpest behaviour difference between the adapters, and it is
|
|
610
|
+
silent — nothing warns you.
|
|
611
|
+
|
|
612
|
+
| adapter | a rotating body |
|
|
613
|
+
| --- | --- |
|
|
614
|
+
| **builtin** | rotates **visually only**. `body.angle`, `setAngle()` and angular integration write `renderable.currentTransform`; the collision shapes are never rotated, so a spinning sprite collides as if it were upright |
|
|
615
|
+
| **planck** / **matter** | rotates for real — the solver owns the body's transform and collision follows it |
|
|
616
|
+
|
|
617
|
+
So a turret, a swinging platform or a tumbling crate that must *collide*
|
|
618
|
+
rotated needs planck or matter. Under the builtin solver, approximate it with a
|
|
619
|
+
shape that is close enough at every angle (a circle, or a square for
|
|
620
|
+
90° steps), or rotate the shapes yourself with `body.rotate(angle)` — which
|
|
621
|
+
does rotate them, unlike `setAngle()`.
|
|
622
|
+
|
|
623
|
+
`body.rotate()` applies a **delta** and does not update `body.angle`; the two
|
|
624
|
+
are unlinked, so a body driven by `rotate()` still reports an angle of `0`.
|
|
625
|
+
Track it yourself if you need to read it back. Before 20.7 it also threw on a
|
|
626
|
+
`Box3d` or `Point` shape, and did not tell its owner that the body's bounds had
|
|
627
|
+
grown.
|
|
628
|
+
|
|
629
|
+
`adapter.getBodyShapes(renderable)` reports whichever is true: the geometry
|
|
630
|
+
the engine is actually simulating on planck and matter (matter-adapter 1.3.0 /
|
|
631
|
+
planck-adapter 1.4.0 and later), unrotated shapes on the builtin solver because
|
|
632
|
+
there they genuinely are. That is what the debug overlay draws, so the hitbox
|
|
633
|
+
you see is the hitbox that collides — a sprite spinning inside a stationary red
|
|
634
|
+
box on the builtin is the solver telling you the truth, not a drawing bug.
|
|
635
|
+
|
|
636
|
+
On planck and matter that report comes from the engine rather than from your
|
|
637
|
+
definitions, so it shows the approximations they make: an `Ellipse` appears as
|
|
638
|
+
the circle of average radius it is simulated as, a concave polygon as the
|
|
639
|
+
convex pieces it was decomposed into, and a `Rect` as a `Polygon`. Your
|
|
640
|
+
authored shapes are untouched and still readable on `renderable.bodyDef.shapes`.
|
|
641
|
+
|
|
642
|
+
**If you need rotation to affect collision, use planck or matter.** That is the
|
|
643
|
+
dividing line: the builtin is a position-based solver whose SAT never reads
|
|
644
|
+
`body.angle`, so rotation there is a visual property. `body.rotate(angle)` is
|
|
645
|
+
the workaround, not a rotating body — it permanently moves the shapes, does not
|
|
646
|
+
track an angle, and gives you no angular velocity, torque or rotational
|
|
647
|
+
response from a collision. A game whose collision genuinely turns (a spinning
|
|
648
|
+
hazard, a swinging bridge, a car, anything with torque) wants a real rigid-body
|
|
649
|
+
adapter rather than a workaround.
|
|
650
|
+
|
|
345
651
|
## Porting between adapters
|
|
346
652
|
|
|
347
653
|
Same call, different magnitude — these are the ones that waste an afternoon:
|
|
@@ -389,11 +695,22 @@ use them. `adapter.capabilities` (`constraints`,
|
|
|
389
695
|
| `response.depth` / `response.normal` are `undefined` | reading a legacy `onCollision` response — it carries `overlap` / `overlapN` |
|
|
390
696
|
| `onCollisionEnd` handler throws on `response` | built-in dispatches it with `undefined` |
|
|
391
697
|
| off-screen bodies stop simulating | built-in gating on `inViewport`; set `alwaysUpdate` |
|
|
698
|
+
| a body sinks through one shape of a multi-shape body | fixed in 20.7; before that the compound pass only ever re-resolved the first overlapping pair |
|
|
699
|
+
| a body will not stay put on a slope on the builtin | it is riding the slope and sliding: the builtin has no surface friction, only `frictionAir` damping. Damp it yourself, or use matter/planck |
|
|
700
|
+
| the sprite is drawn offset from its hitbox | pre-20.7 `anchorPoint` moved the drawing but not the collision shapes; upgrade, and drop any offsets you added to compensate |
|
|
701
|
+
| a rotated renderable reports an unrotated bounding box | `autoTransform: false` opts `updateBounds()` out of the transform |
|
|
702
|
+
| a body in a pile sinks into the floor (built-in) | fixed in 20.7 for anything with an immovable side; bodies pinned only by other DYNAMIC bodies still overlap by a pixel or two, which is what planck/matter are for |
|
|
392
703
|
| forces do nothing after switching adapter | magnitude units differ — re-tune, don't reuse numbers |
|
|
393
704
|
| `body.position` disagrees with `renderable.pos` on matter | matter stores the centroid, melonJS the top-left — the adapter offsets between them |
|
|
705
|
+
| `bodyDef.shapes: "…"` throws "is not loaded" | the name must match the `name` the JSON was preloaded under, not its filename |
|
|
706
|
+
| everything falls far too fast or too slow after swapping backends | gravity is a different unit per backend; see the table above |
|
|
707
|
+
| debris lands holding its spawn angle and never tumbles | `fixedRotation: true`, or matter-adapter < 1.4.0 / planck-adapter < 1.5.0 |
|
|
708
|
+
| a rotated sprite collides as if upright | the built-in solver rotates visually only — `body.angle` never rotates the shapes. Use planck/matter, or `body.rotate(angle)` |
|
|
709
|
+
| the debug hitbox does not follow a spinning body | pre-1.2.1 matter-adapter / pre-1.3.1 planck-adapter returned the authored shapes rather than the rotated ones |
|
|
394
710
|
| a Tiled polyline becomes a solid box on matter | matter cannot build a zero-area polygon; the adapter falls back to its AABB |
|
|
395
711
|
|
|
396
712
|
## Related skills
|
|
397
713
|
|
|
398
714
|
- `melonjs-renderables` — `isKinematic`, which also gates the broadphase
|
|
399
715
|
- `melonjs-tilemaps` — collision shapes authored in Tiled
|
|
716
|
+
- `melonjs-loading-assets` — preloading a shape editor's export as JSON
|
|
@@ -215,6 +215,18 @@ sprite.alpha = 0; // hides it
|
|
|
215
215
|
|
|
216
216
|
Use `alpha` for a blink, or remove the child for a long absence.
|
|
217
217
|
|
|
218
|
+
## A mask belongs to you, not to the renderable
|
|
219
|
+
|
|
220
|
+
`renderable.mask` takes a shape you created, and `destroy()` releases the
|
|
221
|
+
reference without recycling it: the same instance may still be masking
|
|
222
|
+
something else, so the engine has no claim on it. If you pool masks, release
|
|
223
|
+
them yourself.
|
|
224
|
+
|
|
225
|
+
Before 20.7.0 `destroy()` tried to recycle it and **threw** for every type
|
|
226
|
+
`mask` accepts, because it used the legacy name-keyed pool and no geometry
|
|
227
|
+
class is registered there. It failed mid-teardown, so a masked renderable
|
|
228
|
+
could not be destroyed or removed without keepalive at all.
|
|
229
|
+
|
|
218
230
|
## Update and draw
|
|
219
231
|
|
|
220
232
|
```js
|
|
@@ -260,6 +272,7 @@ Hand-rolled equivalents miss the batching and the multi-backend support.
|
|
|
260
272
|
| object draws at its parent's origin, ignores its position | `draw()` not reading `this.pos` |
|
|
261
273
|
| pointer handler registered but never fires | `isKinematic` left at its `true` default |
|
|
262
274
|
| wrong draw order | anything other than `addChild(child, z)` — see section 3 |
|
|
275
|
+
| `me.pool: object ... cannot be recycled` while destroying | a mask on a renderable, before 20.7.0 |
|
|
263
276
|
| effect cannot be re-enabled after removal | `removePostEffect()` destroyed it |
|
|
264
277
|
| effect silently does nothing | running on the Canvas renderer |
|
|
265
278
|
| object appears frozen while its state changes | `update()` not returning `true` |
|
|
@@ -100,6 +100,15 @@ melonJS pre-registers `Renderable`, `Sprite`, `NineSliceSprite`, `Text`,
|
|
|
100
100
|
`BitmapText`, `ImageLayer`, `ColorLayer`, `Light2d`, `Collectable` and `Trigger`
|
|
101
101
|
as Tiled classes, so `Collectable` and `Trigger` work out of the box.
|
|
102
102
|
|
|
103
|
+
A `Trigger` forwards a **fixed list** of settings to `level.load()` — not
|
|
104
|
+
whatever you pass it. Today that list is `container`, `onLoaded`, `flatten`,
|
|
105
|
+
`setViewportBounds` and the glTF scene options (`scale`, `rightHanded`,
|
|
106
|
+
`lights`, `lightIntensityScale`, `castGroundShadow`, `shadowGroundY`); see the
|
|
107
|
+
3D assets skill. Anything outside it is **dropped silently**, which is worth
|
|
108
|
+
knowing before you spend an afternoon on a map that loads at the wrong scale.
|
|
109
|
+
`async` is excluded deliberately — the trigger needs to sequence its own
|
|
110
|
+
transition.
|
|
111
|
+
|
|
103
112
|
## Camera bounds
|
|
104
113
|
|
|
105
114
|
`level.load` sets the viewport bounds to the map size for you —
|